aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_req.erl
AgeCommit message (Collapse)Author
2012-05-04Add an 'onresponse' hookLoïc Hoguin
This new protocol option is a fun. It expects 3 args: the Status code used in the reply (this is the cowboy_http:status() type, it can be an integer or a binary), the headers that will be sent in the reply, and the Req. It should only return a possibly modified Req. This can be used for many things like error logging or custom error pages. If a reply is sent inside the hook, then Cowboy will discard the reply initially sent. Extra caution must be used in the handlers making use of inline chunked replies as they will throw an error. This fun cannot be used as a filter, you can either observe the reply sent or discard it to send a different one instead. The hook will not be called for replies sent from inside the hook.
2012-05-01Refactor the reply functionsLoïc Hoguin
2012-04-29Fix and rework the HTTP test suiteLoïc Hoguin
Use a proper HTTP client to run all tests. This client is currently undocumented and should not be used. Includes a few fixes: * Fix a bug in the max_keepalive test * Fix a bug with max_keepalive handling * Fix a bug in stream_body/1 where data was lost under some conditions The tests now run quite faster than before. All the tests now run twice: once for TCP, once for SSL.
2012-04-01Add chunked transfer encoding support and rework the body reading APILoïc Hoguin
Introduces 3 low level functions and updates the existing higher levels functions. The new primitives are has_body/1, body_length/1 and stream_body/1. In addition to that, a helper function init_stream/4 has been added. Streaming a body implies to decode the Transfer-Encoding and Content-Encoding used for the body. By default, Cowboy will try to figure out what was used and decode them properly. You can override this if you want to disable this behavior or simply support more encodings by calling the init_stream/4 function before you start streaming the body.
2012-03-13Do not send chunked Transfer-Encoding replies for HTTP/1.0Loïc Hoguin
Fixes compatibility issue #140 reported by @majek.
2012-03-12Rename inet:ip_port() to inet:port_number()Loïc Hoguin
Thanks go to @superbobry for pointing it out.
2012-02-27Remove the redundant include/ from -include("http.hrl")Loïc Hoguin
2012-02-23Add cowboy_http:x_www_form_urlencoded/2Loïc Hoguin
This was initially an internal function, it has been made public due to popular demand as it can sometimes be needed.
2012-02-20Add 'Expect' header parsingLoïc Hoguin
At the same time renaming cowboy_http:content_type_params/3 to cowboy_http:params/2 (with a default Acc of []) as this code isn't useful only for content types.
2012-01-23Rename the type http_status/0 to cowboy_http:status/0Loïc Hoguin
2012-01-23Rename the type http_header/0 to cowboy_http:header/0Loïc Hoguin
At the same time rename http_headers/0 to cowboy_http:headers/0.
2012-01-23Rename the type http_version/0 to cowboy_http:version/0Loïc Hoguin
2012-01-23Rename the type http_method/0 to cowboy_http:method/0Loïc Hoguin
Exported types are much better than include files.
2012-01-23Merge branch 'multipart' of https://github.com/nox/cowboyLoïc Hoguin
Conflicts: src/cowboy_http_req.erl test/http_SUITE.erl
2012-01-23Add multipart supportAnthony Ramine
2012-01-06Fix handler crashes handlingLoïc Hoguin
We try to send a 500 error only if we didn't send the response headers yet. If they were, then we have no way to be sure the response was fully sent, nor should we assume anything about how this will be handled client-side, so we do nothing more and in both cases close the connection.
2012-01-04inet_address:parse/1 does not accept binaries as an input, only stringsYurii Rashkovskii
2012-01-03Merge branch 'static-handler-split' of https://github.com/klaar/cowboyLoïc Hoguin
2011-12-28Add cowboy_http_req:set_resp_body_fun/3.Magnus Klaar
2011-12-28Add cowboy_http_req:transport/1 function.Magnus Klaar
2011-12-22Add 'Upgrade' header parsingLoïc Hoguin
Not parsing product tokens, I don't see much point.
2011-12-19Add meta/2 and meta/3 to cowboy_http_req to save useful protocol informationLoïc Hoguin
* cowboy_http_protocol now defines 'websocket_version' as metadata. * cowboy_http_rest now defines 'media_type', 'language', 'charset' as metadata.
2011-12-19Add missing p_headers and cookies to compacted valuesLoïc Hoguin
2011-12-16update type of resp_body to iodataMagnus Klaar
resp_body is set by cowboy_http_req:set_resp_body/2 which accepts the input type iodata(). Update the resp_body field to use the same type. Also update the cowboy_http_req:has_resp_body/2 function to use the iolist_size/1 which works with both binary() and iolist() values instead of the byte_size/1 function which only works with binary() values.
2011-12-08Merge branch 'master' of https://github.com/erlyvideo/cowboyLoïc Hoguin
Just fixed the indentation a bit.
2011-12-08peer_addr/1 functionMax Lapshin
2011-12-07Merge branch 'noquoted' of https://github.com/klaar/cowboyLoïc Hoguin
2011-12-07replace quoted:from_url with cowboy_http:urldecodeMagnus Klaar
This change makes the dependency on quoted optional by adding a minimal urldecode function to cowboy. A protocol option for setting the urldecoding function has been added to the cowboy_http_protocol module. The default value for this option is set to be equivalent to the default settings for quoted. {fun cowboy_http:urldecode/2, crash} A note has been added in the README to document how to use quoted instead of this function. A field to store this option value has been added to the state record in the cowboy_http_protocol module and the http_req record in include/http.hrl Functions that previously used quoted:from_url/1 has been updated to require an equivalent function in addition to the previously required arguments. This change removes a C compiler from the build requirements of cowboy. It also removes the requirement to cross compile the code if the target arch/OS is different from the arch/OS used to build it.
2011-12-07Add cowboy_http_req:set_resp_cookie/4Loïc Hoguin
Pretty much just an alias for a combination of set_resp_header and cookie.
2011-12-06Simplify the guards for cowboy_http_req:body/2Loïc Hoguin
2011-12-05The semantics for a missing 'If-Match' aren't the same as '*'Loïc Hoguin
2011-12-05Fix specs to allow headers as iodata() and not just binary()Loïc Hoguin
2011-11-28Add set_resp_header/3 and set_resp_body/2 to cowboy_http_reqLoïc Hoguin
These functions allow to set response headers and body in advance, before calling any of the reply functions. Also add has_resp_header/2 and has_resp_body/1 to check if the given response headers have already been set.
2011-11-24Fix default parsed values for the Accept and Accept-* headersLoïc Hoguin
2011-11-10Support 'Content-Type' in parse_header/2Anthony Ramine
2011-11-09Add 'If-Match' and 'If-None-Match' to parse_header/2Loïc Hoguin
2011-11-07Fix reading the request body when Length < byte_size(Buffer)Loïc Hoguin
2011-11-07Add 'Accept-Language' to cowboy_http_req:parse_header/2Loïc Hoguin
2011-11-05Add 'If-Modified-Since' and 'If-Unmodified-Since' to parse_header/2Loïc Hoguin
Implementing the full HTTP-date type (RFC1123, RFC850, asctime).
2011-11-04Merge branch 'parse_header-content-length' of https://github.com/nox/cowboyLoïc Hoguin
Conflicts: src/cowboy_http.erl
2011-11-04Support 'Content-Length' in parse_header/2Anthony Ramine
2011-11-04Rename cowboy_http:charset/2 to conneg/2 and use it for Accept-EncodingLoïc Hoguin
Sorry I apparently used an outdated RFC when I was doing this.
2011-10-29Fix cowboy_http_req:chunk/2 specPaul Oliver
2011-10-26Add 'Accept-Charset' to cowboy_http_req:parse_header/2Loïc Hoguin
2011-10-26Add 'Accept-Encoding' to cowboy_http_req:parse_header/2Loïc Hoguin
2011-10-26Add 'Accept' header parsingLoïc Hoguin
Rework the cowboy_http_req:parse_header/2 function while I was at it.
2011-10-20Parse Connection header tokens in a case-insensitive mannerLoïc Hoguin
2011-10-20Add a cowboy_http_req:upgrade_reply/3 function and use it for websocketsLoïc Hoguin
This function doesn't try to add any additional header besides the Connection: Upgrade header. It also doesn't accept a body. It should be used for the intermediate reply to an upgrade process, before the real reply is sent (if any, for example when using TLS).
2011-10-17Rewrite the token list parsing into separate, modulable functionsLoïc Hoguin
Introduce cowboy_http's list/2, nonempty_list/2, token/2 functions.
2011-10-13Add shortcuts to reply functionsLoïc Hoguin
New functions are reply/2, reply/3, chunked_reply/2 in cowboy_http_req.