aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_protocol.erl
AgeCommit message (Collapse)Author
2011-10-04Remove the connection information from the HTTP protocol stateLoïc Hoguin
Use the Req connection information instead.
2011-10-04Close connection on all errorsLoïc Hoguin
And use a proper cowboy_http_req:reply/4 call for the 204 response.
2011-10-04Small doc clarificationLoïc Hoguin
2011-10-04Do not send a 408 response if the Request-Line wasn't fully receivedLoïc Hoguin
The server should not send a response if there wasn't at least the beginning of a request sent (the Request-Line).
2011-09-30Add cowboy_protocol behaviourMichiel Hakvoort
2011-09-28Improve the error message for HTTP handlersLoïc Hoguin
Making it look more like the websocket handler error messages.
2011-09-14'Host' header is optional in HTTP/1.0Loïc Hoguin
Krishnamurthy, Kristol, Mogul: "Key Differences between HTTP/1.0 and HTTP/1.1", "Internet address conservation". http://www8.org/w8-papers/5c-protocols/key/key.html Fixes issue #35 reported by Alex Kropivny.
2011-09-13Reset the max number of empty lines between keepalive requestsLoïc Hoguin
Fixes issue #47.
2011-08-23Ensure header names are handled in a case insensitive mannerLoïc Hoguin
To this end we are formatting the header names just like OTP does except we do it for names of up to 32 characters, as there are widely used header names of more than 20 characters, the limit that OTP follows currently. An example of such header name would be Sec-Websocket-Version. The formatting itself is fairly simple: an uppercase character at the start and after dashes, everything else lowercase.
2011-08-10Give the ListenerPid to the protocol on startupLoïc Hoguin
Also sends a message 'shoot' that can be received by the protocol to make sure Cowboy has had enough time to fully initialize the socket. This message should be received before any socket-related operations are performed. WebSocket request connections are now moved from the pool 'default' to the pool 'websocket', meaning we can have a lot of running WebSockets despite having a low 'max_connections' setting.
2011-07-07Call Handler:terminate/2 even on error in Handler:handle/2Loïc Hoguin
This ensures we can cleanup what we did in Handler:init/3.
2011-07-06Move recursion out of a try .. catch block.Loïc Hoguin
Fixes issue #31. Recursion shouldn't happen in a single catch statement or inside a try .. catch statement. The only safe construct for catching exceptions and perform recursion when everything goes well is to put the recursive call inside a try .. of .. catch construct in the of .. catch block. Otherwise the stack gets filled with exception-related information since they can still be caught if we were to send them and unfold the whole thing. Thanks go to lpgauth for reporting the issue and people on IRC for explaining the hows and whys.
2011-07-06Add documentation for the public interface.Loïc Hoguin
This is probably not perfect yet but it should be better than nothing. We'll improve things with feedback received from the many users.
2011-05-25Refresh the type specifications.Loïc Hoguin
Following discussions on #erlounge. Also fixes compilation in R14B03 and fixes a few underspecs dialyzer warnings.
2011-05-20Send a meaningful error to error_logger on handler crashes.Loïc Hoguin
Inspired by gen_server and friends. Should fix issue #13.
2011-05-09Implement path_info featureAnthony Ramine
The dispatcher now accepts '...' as the leading segment of Host and the trailing segment of Path, this special atom matches any remaining path tail. When given "cowboy.bugs.dev-extend.eu", host rule ['...', <<"dev-extend">>, <<"eu">>] matches and fills host_info with [<<"cowboy">>, <<"bugs">>]. When given "/a/b/c/d", path rule [<<"a">>, <<"b">>, '...'] matches and fills path_info with [<<"c">>, <<"d">>].
2011-05-08Add chunked reply support.Loïc Hoguin
Send the status line and headers using cowboy_http_req:chunked_reply/3, and individual chunks with cowboy_http_req:chunk/2.
2011-05-05Switch the HTTP protocol to use binary packets instead of lists.Loïc Hoguin
The server now does a single recv (or more, but only if needed) which is then sent to erlang:decode_packet/3 multiple times. Since most requests are smaller than the default MTU on many platforms, we benefit from this greatly. In the case of requests with a body, the server usually read at least part of the body on the first recv. This is bufferized properly and used when later retrieving the body. In the case of pipelined requests, we can end up reading many requests in a single recv, which are then handled properly using only the buffer containing the received data.
2011-05-04Add cowboy_http_req:port/1.Loïc Hoguin
Returns the port given in the Host header if present, otherwise the default port of 443 for HTTPS and 80 for HTTP is returned.
2011-04-30Remove the next_request function always matching its first clause.Loïc Hoguin
2011-04-18Remove the include/types.hrl file.Loïc Hoguin
2011-04-18Move the dispatcher related types into cowboy_dispatcher.Loïc Hoguin
2011-04-18Rename dispatch() into dispatch_rules().Loïc Hoguin
2011-04-18Use the inet:socket() type instead of the user-defined one.Loïc Hoguin
2011-04-12Fix a pattern matching bug in cowboy_http_protocol:handler_init/2.Loïc Hoguin
2011-04-09Limit the number of empty lines to allow before the request-line.Loïc Hoguin
Defaults to 5. Prevents someone from indefinitely sending empty lines.
2011-04-07Don't crash on errors while receiving headers; throw an error 500 instead.Loïc Hoguin
The server shouldn't crash the request process when we have an error while receiving headers. A case where this could happen is if the header line is too long. See also bfrog's report on ticket #3 on github.
2011-04-05Don't automatically retrieve the peer information for the 'OPTIONS' method.Loïc Hoguin
2011-04-05Handle properly the default Connection value for HTTP/1.0.Loïc Hoguin
Fixes a bug reported by evaxsoftware on IRC.
2011-03-27Use a more efficient variant of string:to_lower to improve performance.Loïc Hoguin
After much testing and experimentation of all kinds I find lists to be both faster and using less memory than binaries for request-line and headers handling. This is more than likely due to the fact that headers are very short and thus do not benefit from the advantages of refc binaries, meaning they're copied, just like lists. The memory usage discrepancy is still a mystery for the most part, although the hoops needed to perform operations on the binaries are probably responsible for the extra memory use. I'm thus giving up on trying to use binaries for request-line and headers. Instead, this commit improves performances even more to the lists code, making lists 5% faster than binaries. Lists are easier to work with too, so I guess it's all a big win for everyone. Of course the request body is still read as a binary, we're using the binary type where it performs best.
2011-03-27Match early in connection_to_atom for a small performance improvement.Loïc Hoguin
2011-03-22Allow Handler:init/3 to request a protocol upgrade.Loïc Hoguin
2011-03-22Forward transport and protocol name to Handler:init.Loïc Hoguin
2011-03-22Explicitly ignore the return value of cowboy_http_req:reply in error_response.Loïc Hoguin
2011-03-21Fix spec for cowboy_http_protocol:init/3.Loïc Hoguin
2011-03-21Introduce cowboy_http_req:body/1 to read the full request body.Loïc Hoguin
2011-03-21Make sure error_response always returns ok.Loïc Hoguin
2011-03-21Add specs to ensure_response and change the clauses order.Loïc Hoguin
2011-03-21Skip the request body if it hasn't been read by the handler.Loïc Hoguin
2011-03-20Ensure a response is sent when the handler doesn't reply anything.Loïc Hoguin
2011-03-20Move the error response code into a separate function.Loïc Hoguin
2011-03-20Make sure we can only reply to an HTTP request inside Handler:handle.Loïc Hoguin
Of course since requests are a record the response state can be explicitly overriden, but standard use prevents errors by making sure only one reply is sent.
2011-03-20Lazy-retrieve the peer name and port to avoid wasting time each request.Loïc Hoguin
2011-03-20Change a @todo for Handler:init possible return values.Loïc Hoguin
2011-03-20Rename a variable in cowboy_http_protocol for clarity.Loïc Hoguin
2011-03-20Allow code reloading inside the cowboy_http_protocol module during keep-alive.Loïc Hoguin
2011-03-20Default the connection to keep-alive on HTTP/1.1 and close on 1.0.Loïc Hoguin
2011-03-20Save the raw path string in the request.Loïc Hoguin
2011-03-19Save the raw host string in the request.Loïc Hoguin
2011-03-19Protect the calls to the handler using catch.Loïc Hoguin
* Handler:init shouldn't reply anything; send an error 500. * Handler:handle may have sent something to the client; close the socket. * Handler:terminate failed to clean itself up. Close the socket.