File: h2_streaming.lua

package info (click to toggle)
lua-http 0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid, stretch
  • size: 860 kB
  • ctags: 464
  • sloc: makefile: 59
file content (14 lines) | stat: -rw-r--r-- 412 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
--[[
Makes a request to an HTTP2 endpoint that has an infinite length response.

Usage: lua examples/h2_streaming.lua
]]

local request = require "http.request"

-- This endpoint returns a never-ending stream of chunks containing the current time
local req = request.new_from_uri("https://http2.golang.org/clockstream")
local _, stream = assert(req:go())
for chunk in stream:each_chunk() do
	io.write(chunk)
end