Age | Commit message (Collapse) | Author |
|
Adds a new type of streaming response fun. It can be set in a similar
way to a streaming body fun with known length:
Req2 = cowboy_req:set_resp_body_fun(chunked, StreamFun, Req)
The fun, StreamFun, should accept a fun as its single argument. This
fun, ChunkFun, is used to send chunks of iodata:
ok = ChunkFun(IoData)
ChunkFun should not be called with an empty binary or iolist as this
will cause HTTP 1.1 clients to believe the stream is over. The final (0
length) chunk will be sent automatically - even if it has already been
sent - assuming no exception is raised.
Also note that the connection will close after the last chunk for HTTP
1.0 clients.
|
|
|
|
|
|
|
|
|
|
This kind of function is highly dependent on the proxy used,
therefore parsing was added for x-forwarded-for instead and we
just let users write the function that works for them. The code
can be easily extracted if anyone was using the function.
|
|
|
|
|
|
|
|
Make them consistent with the rest of the module.
|
|
This allows us to change the max chunk length on a per chunk basis
instead of for the whole stream. It's also much easier to use this
way even if we don't want to change the chunk size.
|
|
|
|
Defaults to a maximum of 1000000 bytes.
Also standardize the te_identity and te_chunked decoding functions.
Now they both try to read as much as possible (up to the limit),
making body reading much faster when not using chunked encoding.
|
|
|
|
|
|
|
|
|
|
We now read from the socket to be able to detect errors or TCP close
events, and buffer the data if any. Once the data receive goes over
a certain limit, which defaults to 5000 bytes, we simply close the
connection with an {error, overflow} reason.
|
|
We now obtain the peer address before creating the Req object.
If an error occurs, then something went wrong, we close the connection
nicely directly.
|
|
|
|
|
|
|
|
Basic HTTP authorization according to RFC 2617 is implemented.
Added an example of its usage with REST handler.
|
|
|
|
Types and code are moved to cowboy_router. The match/3 export
from cowboy_dispatcher isn't available anymore as it is called
internally.
|
|
Reported and fixed over email by Adrian Roe.
|
|
|
|
This makes it similar to the other has_* functions.
|
|
|
|
|
|
This behavior can be enabled with the `compress` protocol option.
See the `compress_response` example for more details.
All tests are now ran with and without compression for both HTTP
and HTTPS.
|
|
This allows streaming a body without knowing the length in advance.
Also allows {stream, StreamFun} response body in the REST code.
|
|
It was added to help with response body streaming functions.
But it was a clumsy solution that we discarded in favor of
passing socket and transport to said function. It was also
very odd compared to the rest of the cowboy_req interface.
If you used this function before, worry not, here's its
proper equivalent.
[Socket, Transport] = cowboy_req:get([socket, transport], Req)
|
|
Before we were required to get the socket and transport ourselves,
now they're passed to the function.
|
|
|
|
This function was badly thought out and would cause more harm
than good if used at all. Recommendation will be for people
who need to limit body length to check it beforehand or when
not possible to use the stream_body API.
|
|
This reverts commit cc65a723d70bb078b048bab81eeb8a4bd7ed39ce.
|
|
|
|
|
|
No more trying to quote, this is still completely broken everywhere.
|
|
Includes:
* cowboy_clock:rfc2109/1 now expects UTC datetime
* Rewrite of the cookie code to cowboy_http
* Removal of cowboy_cookies
* Add type cowboy_req:cookie_opts/0
Cookies should now be set using cowboy_req:set_resp_cookie/3.
Code calling cowboy_cookies directly will need to be updated.
|
|
this can happen when the request parsing fails and onresponse
needs the url, its perfectly possible that the url has not
yet been defined
|
|
|
|
This commit closes #195, closes #199, closes #246.
|
|
As suggested by @yrashk.
|
|
We do not always provide the body however. It is not available
when using chunked replies, or when using set_resp_body_fun.
|
|
|
|
|
|
fix typo in doc
|
|
|