aboutsummaryrefslogtreecommitdiffstats
path: root/test/http_SUITE.erl
AgeCommit message (Collapse)Author
2015-05-05Add rfc7230 test suite and update others to recent GunLoïc Hoguin
This is a large commit. The rfc7230 test suite adds many tests from the RFC7230 document. Gun has been updated quite a bit recently, which broke the Cowboy suites. This is now fixed with this commit. A new hook onfirstrequest has been added. It was very useful during debugging of the test suites. The initial process code has changed a little; more changes are expected with the switch to maps for options.
2015-02-04Use cowlib for parsing headers; remove cowboy_httpLoïc Hoguin
2014-11-07Rename 'halt' to 'stop' for better consistencyLoïc Hoguin
Now everywhere in Cowboy when we want to stop something we return a 'stop' tuple instead of one of the many choices depending on context that we had before. This particular change affects middlewares, sub protocols and REST handlers which were using 'halt' to stop processing.
2014-10-03Fix two edge cases when the request-line provided is invalidLoïc Hoguin
2014-09-30Improve handler interface and documentationLoïc Hoguin
This change simplifies a little more the sub protocols mechanism. Aliases have been removed. The renaming of loop handlers as long polling handlers has been reverted. Plain HTTP handlers now simply do their work in the init/2 callback. There is no specific code for them. Loop handlers now follow the same return value as Websocket, they use ok to continue and shutdown to stop. Terminate reasons for all handler types have been documented. The terminate callback is now appropriately called in all cases (or should be). Behaviors for all handler types have been moved in the module that implement them. This means that cowboy_handler replaces the cowboy_http_handler behavior, and similarly cowboy_loop replaces cowboy_loop_handler, cowboy_websocket replaces cowboy_websocket_handler. Finally cowboy_rest now has the start of a behavior in it and will have the full list of optional callbacks defined once Erlang 18.0 gets released. The guide has been reorganized and should be easier to follow.
2014-09-24Remove the onrequest hookLoïc Hoguin
It was redundant with middlewares. Allows us to save a few operations for every incoming requests.
2014-09-23Breaking update of the cowboy_req interfaceLoïc Hoguin
Simplify the interface for most cowboy_req functions. They all return a single value except the four body reading functions. The reply functions now only return a Req value. Access functions do not return a Req anymore. Functions that used to cache results do not have a cache anymore. The interface for accessing query string and cookies has therefore been changed. There are now three query string functions: qs/1 provides access to the raw query string value; parse_qs/1 returns the query string as a list of key/values; match_qs/2 returns a map containing the values requested in the second argument, after applying constraints and default value. Similarly, there are two cookie functions: parse_cookies/1 and match_cookies/2. More match functions will be added in future commits. None of the functions return an error tuple anymore. It either works or crashes. Cowboy will attempt to provide an appropriate status code in the response of crashed handlers. As a result, the content decode function has its return value changed to a simple binary, and the body reading functions only return on success.
2014-07-14Support ad-hoc keep-alive for HTTP/1.0 ClientsFred Hebert
Only go for keep-alive if they submit a 'connection: keep-alive' header in the request, keep behaviour the same otherwise. The new RFC 7230 (http://tools.ietf.org/html/rfc7230#section-6.3) states: If the received protocol is HTTP/1.0, the "keep-alive" connection option is present, the recipient is not a proxy, and the recipient wishes to honor the HTTP/1.0 "keep-alive" mechanism, the connection will persist after the current response; Even though clients are discouraged from doing so in Appendix A.1.2 (http://tools.ietf.org/html/rfc7230#appendix-A.1.2)
2014-07-12Reply with 400 on header parsing crashLoïc Hoguin
This is a first step to improve the HTTP status codes returned by Cowboy on crashes. We will tweak it over time. Also fixes a small bug where two replies may have been sent when using loop handlers under rare conditions.
2014-06-30Return 422 instead of 400 when AcceptResource returns falseLoïc Hoguin
422 is undefined for HTTP and interpreted as 400.
2014-06-10Allow users to pass a raw binary() as the expires header.Drew Varner
2014-06-02Add request body reading optionsLoïc Hoguin
The options were added to allow developers to fix timeout issues when reading large bodies. It is also a cleaner and easier to extend interface. This commit deprecates the functions init_stream, stream_body and skip_body which are no longer needed. They will be removed in 1.0. The body function can now take an additional argument that is a list of options. The body_qs, part and part_body functions can too and simply pass this argument down to the body call. There are options for disabling the automatic continue reply, setting a maximum length to be returned (soft limit), setting the read length and read timeout, and setting the transfer and content decode functions. The return value of the body and body_qs have changed slightly. The body function now works similarly to the part_body function, in that it returns either an ok or a more tuple depending on whether there is additional data to be read. The body_qs function can return a badlength tuple if the body is too big. The default size has been increased from 16KB to 64KB. The default read length and timeout have been tweaked and vary depending on the function called. The body function will now adequately process chunked bodies, which means that the body_qs function will too. But this means that the behavior has changed slightly and your code should be tested properly when updating your code. The body and body_qs still accept a length as first argument for compatibility purpose with older code. Note that this form is deprecated and will be removed in 1.0. The part and part_body function, being new and never having been in a release yet, have this form completely removed in this commit. Again, while most code should work as-is, you should make sure that it actually does before pushing this to production.
2014-04-26Add a test for multipart over chunked transfer-encodingLoïc Hoguin
2014-04-26Make loop handlers work with SPDYLoïc Hoguin
Adds a loop_handler test suite that runs all tests under HTTP, HTTPS, SPDY each with and without the compress option enabled. Fixes output filtering that used to filter more than it should have. This forces us to parse the string sent by the emulator, which means it's probably not perfect yet. But it should at least not hide errors we want to see. Fix a crash in the output filtering code that entirely disabled output. Now when there is a crash the normal tty output is restored. Handlers are now in test/handlers/ as they can be reused between suites. Only generate a single certificate for the whole ct run to speed things up when we got many different test groups each needing certificates.
2014-04-24Fix two issues where listeners didn't get stopped properlyLoïc Hoguin
2014-04-22Move listener initialization to cowboy_testLoïc Hoguin
2014-04-22Start applications directly from the ct hookLoïc Hoguin
2014-04-20Enable Autobahn Test Suite by defaultLoïc Hoguin
Includes a variety of small changes that are a first step to improving the test system heavily.
2014-04-17Cleanup the configuration handling in http_SUITELoïc Hoguin
2014-04-11Fix application start order in tests, gun depends on cowlibLoïc Hoguin
2014-03-24Remove cowboy_client; use gun for the HTTP test suiteLoïc Hoguin
2014-02-06Add and document the new multipart codeLoïc Hoguin
The old undocumented API is removed entirely. While a documentation exists for the new API, it will not be considered set in stone until further testing has been performed, and a file upload example has been added. The new API should be a little more efficient than the old API, especially with smaller messages.
2013-12-28Fix a small typo in a testLoïc Hoguin
2013-11-18Fix loop handler keepalive race conditionJames Fish
Previously if a loop handler received the timeout message from a previous request on the same connection the socket would be set to {active, once} incorrectly - when a socket packet was already in the message queue. This second packet would not be added to the buffer before a Handler:info/3 call if a user message was in the message queue before both socket packets.
2013-11-08Add a workaround to disable chunked transfer-encodingAdrian Roe
This is an undocumented workaround to disable chunks when using HTTP/1.1. It can be used when the client advertises itself as HTTP/1.1 despite not understanding the chunked transfer-encoding. Usage can be found looking at the test for it. When activated, Cowboy will still advertise itself as HTTP/1.1, but will send the body the same way it would if it was HTTP/1.0.
2013-11-02Review, improve and document the static files handlerLoïc Hoguin
Changes include: * Much simplified route configuration. * Etag generation is now enabled by default. * Web mimetypes are now detected by default. A bigger list of mimetypes can be detected without any additional library. * Mimetypes can no longer be specified as a list. Copying this list for new connections is too costy. You can easily convert it into a function and pass that function to the handler instead. * You can however specify a single hardcoded mimetype. Mostly useful when serving a single file, like an index.html file, to avoid extra operations. * Specifying a path as a list of tokens is not possible anymore. Use either a binary or a string. * Using a private directory will not work if the application was not started properly. Cowboy will not attempt to find the location of this directory if the VM doesn't know it, as this caused issues in some setups. * Overall the code has been much simplified and clarified, and of course has now been documented.
2013-09-04Make cowlib a proper dependencyLoïc Hoguin
Start moving a few functions from Cowboy into cowlib.
2013-09-03add some tests for Host header parserYAMAMOTO Takashi
2013-07-12Merge branch 'fix-chunked-req' of git://github.com/fishcakez/cowboyLoïc Hoguin
2013-07-05Fix decoding of chunked body.James Fish
Previously cowboy_http:te_chunked/2 would enter an incorrect state if it tried to parse an incomplete chunk when the length was known from the partial chunk. Previosuly cowboy_http:te_chunked/2 expected the trailing "\r\n" to always be present if chunk body was present in the buffer. This is not guaranteed and so this commit accommodates that situation.
2013-06-29Merge branch 'fix/http-tests-get-mtu' of git://github.com/soundrop/cowboyLoïc Hoguin
2013-06-20Add asn1 to the list of applications to be started for SSLLoïc Hoguin
Required since R16B01. And apparently needed in some cases before.
2013-06-13Use ct_helper for retrieving the loopack interface MTUAli Sabil
2013-06-10Improve the detection of localhost interfaces for the HTTP test suiteAli Sabil
2013-06-07Fix the reading of the localhost MTU in the HTTP testsAli Sabil
Sometimes the localhost interface has a different name from "lo", this fix adds a helper function to read the MTU value when the interface name starts with "lo".
2013-06-03Move static files creation into ct_helperLoïc Hoguin
2013-05-31In content-types, the charset parameter is converted to lowercaseLoïc Hoguin
We know this specific parameter is case insensitive so we automatically lowercase it to make things simpler to the developer.
2013-05-01Update Ranch to 0.8.2 and use ct_helper for testing SSLLoïc Hoguin
2013-04-26Add chunked response body funJames Fish
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.
2013-04-26Merge branch 'fix-tests' of git://github.com/fishcakez/cowboyLoïc Hoguin
2013-04-26Merge branch 'pr-381-fix' of git://github.com/seletskiy/cowboyLoïc Hoguin
2013-04-26Add default CTP: "text/html" maps to `to_html`Seletskiy Stanislav
2013-04-26Fix memory issue with large return values in testcasesJames Fish
Previously http_SUITE:echo_body/1 and http_SUITE:check_raw_status/1 returned large values. Common test would then try to write these to the logs causing tests to take a long time and use lots of memory.
2013-04-24Reorganize the http test suiteLoïc Hoguin
2013-04-22Move SSL test certificates in a subdirectoryLoïc Hoguin
2013-04-12Add default operations for OPTIONS method in RESTLoïc Hoguin
It defaults to setting the Allow header to "HEAD, GET, OPTIONS".
2013-04-12Ensure we can fetch the body in the info/3 function of loop handlersLoïc Hoguin
2013-04-12rest: reject incorrect content-type headerVladimir Dronnikov
2013-04-11Remove process_post, post_is_create, create_path, created_path callbacksLoïc Hoguin
Instead it will always go through content_types_accepted and it is up to the resource code to do any creation and to return the created path if the method is POST and the client should be redirected to the created resource's location. This removes the meta value 'put_path' as it is not needed anymore. This fixes an issue with PATCH where content types were not normalized.
2013-03-06Check the length before reading the body in body/1 and body_qs/1rambocoder