aboutsummaryrefslogtreecommitdiffstats
path: root/test/http_SUITE.erl
AgeCommit message (Collapse)Author
2012-09-21Make multipart part headers binary lowercaseLoïc Hoguin
Here we do not remove decode_packet yet, we just lowercase the header name and transform it into a binary if needed, to fix the consistency issue.
2012-09-21Don't use decode_packet/3 for parsing the headersLoïc Hoguin
Header names are now binaries. Since header names are case insensitive they are all converted to lowercase. For example: <<"content-length">>. The max_line_length option was removed. Three new options have been added instead: * max_request_line_length (defaults to 4096) * max_header_name_length (defaults to 64) * max_header_value_length (defaults to 4096)
2012-09-21Don't use decode_packet/3 for parsing the request-lineLoïc Hoguin
First step in making all methods and header names binaries to get rid of many inconsistencies caused by decode_packet/3. Methods are all binary now. Note that since they are case sensitive, the usual methods become <<"GET">>, <<"POST">> and so on.
2012-09-17Improve consistency of return types for cowboy_req APILoïc Hoguin
The signature of parse_header, body_qs, multipart_data and the set_resp_* functions has changed. See the cowboy_req module edoc for more details.
2012-08-27Rename cowboy_http_static to cowboy_staticLoïc Hoguin
2012-08-27Rename cowboy_http_req to cowboy_reqLoïc Hoguin
2012-08-27Rename cowboy_http_protocol to cowboy_protocolLoïc Hoguin
2012-08-27Switch to Ranch for connection handlingLoïc Hoguin
This is the first of many API incompatible changes. You have been warned.
2012-05-23Update version to 0.6.00.6.0Loïc Hoguin
Also update the CHANGELOG and copyright years.
2012-05-21Remove a dumb warning when running the testsLoïc Hoguin
2012-05-21Merge branch 'serve-static-file' of https://github.com/klaar/cowboyLoïc Hoguin
Fix alphabetical order since @klaar seems to have issues with it. ;)
2012-05-21Fix a bug preventing 'onresponse' from being called on errorsLoïc Hoguin
2012-05-21Small updates to the ROADMAP and doc commentsLoïc Hoguin
2012-05-05Add a test checking requests with size around the MTULoïc Hoguin
2012-05-04Merge branch 'response-hook'Loïc Hoguin
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-02Add a test for HTTP handlers loop timeoutsLoïc Hoguin
2012-04-30Add file option to cowboy_http_staticMagnus Klaar
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-15Add an 'onrequest' hook for HTTPLoïc Hoguin
This new protocol option is a fun. It expects a single arg, the Req, and should only return a possibly modified Req. This can be used for many things like URL rewriting, access logging or listener-wide authentication. If a reply is sent inside the hook, then Cowboy will consider the request handled and will move on to the next one.
2012-03-13Do not send chunked Transfer-Encoding replies for HTTP/1.0Loïc Hoguin
Fixes compatibility issue #140 reported by @majek.
2012-02-29Tests and fixes for the generate_etag/2 callbackMagnus Klaar
The return value from the generate_etag/2 callback is expected to be a binary tagged with either weak or strong. This binary is quoted, and may be prefixed with W/ before it is set as the value of the ETag header in the response. For backwards compatibility with older handlers where the return value was expected to be a quoted binary a function has been added to parse any return values that are untagged binaries. All untagged binaries are expected to be a valid value for the ETag header.
2012-02-02Added absoluteURI supportDavid Kelly
If requests go through a proxy, they will have the original uri in the request, i.e. : GET http://proxy.server.uri/some/query/string HTTP 1.1 ... That was problematic -- cowboy_http_protocol:request didn't know what to to with the result of decode_packet applied to this, which would be something like: ``` erlang {http_request,'GET',{absoluteURI,http,<<"proxy.server.uri">>, undefined,<<"/some/query/string">>},{1,1}} ``` So, I just ignore the host, grab the path and pass into ``` erlang cowboy_http_protocol:request({http_request, Method, {abs_path, Path}, Version}, State) ``` Seems to do the trick without much effort.
2012-01-26Remove a leftover ct:printLoïc Hoguin
2012-01-26Handle delete better when no delete_resource function is implementedTom Burdick
2012-01-23Merge branch 'master' of https://github.com/bfrog/cowboyLoïc Hoguin
2012-01-23added test for posting to a rest controller where forbidden returns true on ↵Tom Burdick
a keep alive socket
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-07Add etag option to cowboy_http_static handler.Magnus Klaar
2012-01-06Fix the stream_body_set_resp testLoïc Hoguin
It was failing from time to time due to the response being sent as two separate packets.
2012-01-06Merge branch 'issue-114-tests' of https://github.com/klaar/cowboy into ↵Loïc Hoguin
gracefully-handle-crashes Conflicts: test/http_SUITE.erl
2012-01-05only run end_static_dir for http and httpsMagnus Klaar
2012-01-05Add test and doc for content types function.Magnus Klaar
2011-12-29Add tests for #114Magnus Klaar
2011-12-28Add built-in cowboy_http_static handler.Magnus Klaar
2011-12-28Add cowboy_http_req:set_resp_body_fun/3.Magnus Klaar
2011-12-22Add a max_keepalive HTTP protocol optionLoïc Hoguin
Based on the patch by Louis-Philippe Gauthier.
2011-12-22Move the websocket tests in a separate suiteLoïc Hoguin
2011-12-08Allow HTTP protocol upgrades to use keepaliveLoïc Hoguin
REST needed this to be allowed to chain requests on the same connection.
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-06cowboy_http_protocol shouldn't crash if the client sends HTTP responsesLoïc Hoguin
It was replying back the correct error, but with a crash message in the console. This patch prevents it from crashing. Fixes issue #94 reported by oribrost.
2011-12-05Add experimental Webmachine based REST protocol supportLoïc Hoguin
As with everything experimental, it probably has a lot of bugs and may not even work. Like Websocket, REST must be upgraded from a standard resource through the init/3 function. A key difference between Webmachine and Cowboy's REST protocol handler is that in Cowboy the resource has direct access to the request object. This makes a small change in a few places where you were expected to return headers or body in Webmachine and are now expected to set them directly yourself if needed (options/2, for example). Another difference is that the functions rest_init/2 will always be called when starting to process a request. Similarly, rest_terminate/2 will be called when the process completes successfully. The Cowboy REST support also includes automatic language selection, thanks to the languages_provided/2 callback. Finally, Cowboy REST expects full URIs to be given at all times, and will not try to reconstruct URIs from fragments. Note that REST requests cannot be chained (keepalive) at this time. This is a design issue in cowboy_http_protocol that will be fixed soon. Check out the source for more details. It has been designed to be very easy to read and understand so if you don't understand something, it's probably a bug. Thanks in advance for all the great bug reports, pull requests and comments you'll forward my way!
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-10-24Accept Sec-WebSocket-Version: 13 header on Chrome 15 through 17Paul Oliver
2011-10-20Make sure the hixie-76 websocket code works properly with proxiesLoïc Hoguin
2011-10-19Add a max_line_length to the HTTP protocolLoïc Hoguin
Allows to limit the size of request and header lines, thus preventing Cowboy from infinitely reading from the socket and never finding an end of line. Defaults to 4096 bytes.
2011-10-10Add support for loops in standard HTTP handlersLoïc Hoguin
Now init/3 can return one of the following values to enable loops: - {loop, Req, State} - {loop, Req, State, hibernate} - {loop, Req, State, Timeout} - {loop, Req, State, Timeout, hibernate} Returning one of these tuples will activate looping in the HTTP handler. When looping, handle/2 is never called. Instead, Cowboy will listen for Erlang messages and forward them to the info/3 function of the handler. If a timeout is defined, Cowboy will also close the connection when no message has been received for Timeout milliseconds. The info/3 function is defined as info(Msg, Req, State). It can return either of the following tuples: - {ok, Req, State} - {loop, Req, State} - {loop, Req, State, hibernate} The first one ends the connection, calling terminate/2 before closing. The others continue the loop. Loops are useful when writing long-polling handlers that need to wait and don't expect to receive anything. Therefore it is recommended to set a timeout to close the connection if nothing arrives after a while and to enable hibernate everywhere. Normal HTTP handlers shouldn't need to use this and as such info/3 was made optional.
2011-10-10Add {shutdown, Req} to websocket_init/3 to fail a websocket upgradeLoïc Hoguin
This change allows application developers to refuse websocket upgrades by returning {shutdown, Req}. The application can also send a reply with a custom error before returning from websocket_init/3, otherwise an error 400 is sent. Note that right now Cowboy closes the connection immediately. Also note that neither terminate/3 nor websocket_terminate/3 will be called when the connection is shutdown by websocket_init/3.