Skip to content

Commit

Permalink
protocol tweaks
Browse files Browse the repository at this point in the history
- allow PUT as an HTTP verb
- as per RFC2616, trailing CRLF is disallowed.
  • Loading branch information
evanmcc committed Sep 13, 2017
1 parent 311d135 commit 728bc73
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/buoy_protocol.erl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ request(Method, Path, Headers, Host, undefined) ->
<<"Host: ">>, Host,
<<"\r\nConnection: Keep-alive\r\n">>,
<<"User-Agent: buoy\r\n">>,
format_headers(Headers), <<"\r\n">>];
format_headers(Headers)];
request(Method, Path, Headers, Host, Body) ->
ContentLength = integer_to_binary(iolist_size(Body)),
Headers2 = [{<<"Content-Length">>, ContentLength} | Headers],
Expand All @@ -55,7 +55,7 @@ request(Method, Path, Headers, Host, Body) ->
<<"\r\nConnection: Keep-alive\r\n">>,
<<"User-Agent: buoy\r\n">>,
format_headers(Headers2), <<"\r\n">>,
Body, <<"\r\n">>].
Body].

-spec response(binary()) ->
{ok, buoy_resp(), binary()} | error().
Expand Down Expand Up @@ -134,7 +134,9 @@ content_length([_ | T]) ->
format_method(get) ->
<<"GET">>;
format_method(post) ->
<<"POST">>.
<<"POST">>;
format_method(put) ->
<<"PUT">>.

format_headers(Headers) ->
[format_header(Header) || Header <- Headers].
Expand Down

0 comments on commit 728bc73

Please sign in to comment.