1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
## http.h1_stream
The *h1_stream* module adheres to the [*stream*](#stream) interface and provides HTTP 1.x specific operations.
The gzip transfer encoding is supported transparently.
### `h1_stream.connection` <!-- --> {#http.h1_stream.connection}
See [`stream.connection`](#stream.connection)
### `h1_stream.max_header_lines` <!-- --> {#http.h1_stream.max_header_lines}
The maximum number of header lines to read. Default is `100`.
### `h1_stream:checktls()` <!-- --> {#http.h1_stream:checktls}
See [`stream:checktls()`](#stream:checktls)
### `h1_stream:localname()` <!-- --> {#http.h1_stream:localname}
See [`stream:localname()`](#stream:localname)
### `h1_stream:peername()` <!-- --> {#http.h1_stream:peername}
See [`stream:peername()`](#stream:peername)
### `h1_stream:get_headers(timeout)` <!-- --> {#http.h1_stream:get_headers}
See [`stream:get_headers(timeout)`](#stream:get_headers)
### `h1_stream:write_headers(headers, end_stream, timeout)` <!-- --> {#http.h1_stream:write_headers}
See [`stream:write_headers(headers, end_stream, timeout)`](#stream:write_headers)
### `h1_stream:write_continue(timeout)` <!-- --> {#http.h1_stream:write_continue}
See [`stream:write_continue(timeout)`](#stream:write_continue)
### `h1_stream:get_next_chunk(timeout)` <!-- --> {#http.h1_stream:get_next_chunk}
See [`stream:get_next_chunk(timeout)`](#stream:get_next_chunk)
### `h1_stream:each_chunk()` <!-- --> {#http.h1_stream:each_chunk}
See [`stream:each_chunk()`](#stream:each_chunk)
### `h1_stream:get_body_as_string(timeout)` <!-- --> {#http.h1_stream:get_body_as_string}
See [`stream:get_body_as_string(timeout)`](#stream:get_body_as_string)
### `h1_stream:get_body_chars(n, timeout)` <!-- --> {#http.h1_stream:get_body_chars}
See [`stream:get_body_chars(n, timeout)`](#stream:get_body_chars)
### `h1_stream:get_body_until(pattern, plain, include_pattern, timeout)` <!-- --> {#http.h1_stream:get_body_until}
See [`stream:get_body_until(pattern, plain, include_pattern, timeout)`](#stream:get_body_until)
### `h1_stream:save_body_to_file(file, timeout)` <!-- --> {#http.h1_stream:save_body_to_file}
See [`stream:save_body_to_file(file, timeout)`](#stream:save_body_to_file)
### `h1_stream:get_body_as_file(timeout)` <!-- --> {#http.h1_stream:get_body_as_file}
See [`stream:get_body_as_file(timeout)`](#stream:get_body_as_file)
### `h1_stream:unget(str)` <!-- --> {#http.h1_stream:unget}
See [`stream:unget(str)`](#stream:unget)
### `h1_stream:write_chunk(chunk, end_stream, timeout)` <!-- --> {#http.h1_stream:write_chunk}
See [`stream:write_chunk(chunk, end_stream, timeout)`](#stream:write_chunk)
### `h1_stream:write_body_from_string(str, timeout)` <!-- --> {#http.h1_stream:write_body_from_string}
See [`stream:write_body_from_string(str, timeout)`](#stream:write_body_from_string)
### `h1_stream:write_body_from_file(options|file, timeout)` <!-- --> {#http.h1_stream:write_body_from_file}
See [`stream:write_body_from_file(options|file, timeout)`](#stream:write_body_from_file)
### `h1_stream:shutdown()` <!-- --> {#http.h1_stream:shutdown}
See [`stream:shutdown()`](#stream:shutdown)
### `h1_stream:set_state(new)` <!-- --> {#http.h1_stream:set_state}
Sets the state of the stream to `new`. `new` must be one of the following valid states:
- `"open"`: have sent or received headers; haven't sent body yet
- `"half closed (local)"`: have sent whole body
- `"half closed (remote)"`: have received whole body
- `"closed"`: complete
Not all state transitions are allowed.
### `h1_stream:read_headers(timeout)` <!-- --> {#http.h1_stream:read_headers}
Reads and returns a [header block](#http.headers) from the underlying connection. Does *not* take into account buffered header blocks. On error, returns `nil`, an error message and an error number.
This function should rarely be used, you're probably looking for [`:get_headers()`](#http.h1_stream:get_headers).
### `h1_stream:read_next_chunk(timeout)` <!-- --> {#http.h1_stream:read_next_chunk}
Reads and returns the next chunk as a string from the underlying connection. Does *not* take into account buffered chunks. On error, returns `nil`, an error message and an error number.
This function should rarely be used, you're probably looking for [`:get_next_chunk()`](#http.h1_stream:get_next_chunk).
|