mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Remove any mention of the waiting_stream hack
This commit is contained in:
parent
acc5fed589
commit
3c18585945
3 changed files with 14 additions and 42 deletions
|
@ -46,16 +46,17 @@ implementations. There is no easy solution for this other than
|
||||||
forking the project and editing the `cowboy_protocol` file
|
forking the project and editing the `cowboy_protocol` file
|
||||||
directly.
|
directly.
|
||||||
|
|
||||||
=== Chunked transfer-encoding
|
// @todo This currently has no equivalent in Cowboy 2.0.
|
||||||
|
// === Chunked transfer-encoding
|
||||||
Sometimes an HTTP client advertises itself as HTTP/1.1 but
|
//
|
||||||
does not support chunked transfer-encoding. This is invalid
|
// Sometimes an HTTP client advertises itself as HTTP/1.1 but
|
||||||
behavior, as HTTP/1.1 clients are required to support it.
|
// does not support chunked transfer-encoding. This is invalid
|
||||||
|
// behavior, as HTTP/1.1 clients are required to support it.
|
||||||
A simple workaround exists in these cases. By changing the
|
//
|
||||||
Req object response state to `waiting_stream`, Cowboy will
|
// A simple workaround exists in these cases. By changing the
|
||||||
understand that it must use the identity transfer-encoding
|
// Req object response state to `waiting_stream`, Cowboy will
|
||||||
when replying, just like if it was an HTTP/1.0 client.
|
// understand that it must use the identity transfer-encoding
|
||||||
|
// when replying, just like if it was an HTTP/1.0 client.
|
||||||
[source,erlang]
|
//
|
||||||
Req2 = cowboy_req:set(resp_state, waiting_stream).
|
// [source,erlang]
|
||||||
|
// Req2 = cowboy_req:set(resp_state, waiting_stream).
|
||||||
|
|
|
@ -103,7 +103,6 @@ init_dispatch(Config) ->
|
||||||
cowboy_router:compile([
|
cowboy_router:compile([
|
||||||
{"localhost", [
|
{"localhost", [
|
||||||
{"/chunked_response", http_chunked, []},
|
{"/chunked_response", http_chunked, []},
|
||||||
{"/streamed_response", http_streamed, []},
|
|
||||||
{"/headers/dupe", http_handler,
|
{"/headers/dupe", http_handler,
|
||||||
[{headers, #{<<"connection">> => <<"close">>}}]},
|
[{headers, #{<<"connection">> => <<"close">>}}]},
|
||||||
{"/set_resp/header", http_set_resp,
|
{"/set_resp/header", http_set_resp,
|
||||||
|
@ -807,20 +806,6 @@ stream_body_set_resp_chunked10(Config) ->
|
||||||
{ok, <<"stream_body_set_resp_chunked">>} = gun:await_body(ConnPid, Ref),
|
{ok, <<"stream_body_set_resp_chunked">>} = gun:await_body(ConnPid, Ref),
|
||||||
gun_down(ConnPid).
|
gun_down(ConnPid).
|
||||||
|
|
||||||
%% Undocumented hack: force chunked response to be streamed as HTTP/1.1.
|
|
||||||
streamed_response(Config) ->
|
|
||||||
Client = raw_open(Config),
|
|
||||||
ok = raw_send(Client, "GET /streamed_response HTTP/1.1\r\nHost: localhost\r\n\r\n"),
|
|
||||||
Data = raw_recv_head(Client),
|
|
||||||
{'HTTP/1.1', 200, _, Rest} = cow_http:parse_status_line(Data),
|
|
||||||
{Headers, Rest2} = cow_http:parse_headers(Rest),
|
|
||||||
false = lists:keymember(<<"transfer-encoding">>, 1, Headers),
|
|
||||||
Rest2Size = byte_size(Rest2),
|
|
||||||
ok = case <<"streamed_handler\r\nworks fine!">> of
|
|
||||||
Rest2 -> ok;
|
|
||||||
<< Rest2:Rest2Size/binary, Expect/bits >> -> raw_expect_recv(Client, Expect)
|
|
||||||
end.
|
|
||||||
|
|
||||||
te_chunked(Config) ->
|
te_chunked(Config) ->
|
||||||
Body = list_to_binary(io_lib:format("~p", [lists:seq(1, 100)])),
|
Body = list_to_binary(io_lib:format("~p", [lists:seq(1, 100)])),
|
||||||
ConnPid = gun_open(Config),
|
ConnPid = gun_open(Config),
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
%% Feel free to use, reuse and abuse the code in this file.
|
|
||||||
|
|
||||||
-module(http_streamed).
|
|
||||||
|
|
||||||
-export([init/2]).
|
|
||||||
|
|
||||||
init(Req, Opts) ->
|
|
||||||
Req2 = cowboy_req:set([{resp_state, waiting_stream}], Req),
|
|
||||||
Req3 = cowboy_req:chunked_reply(200, Req2),
|
|
||||||
timer:sleep(100),
|
|
||||||
cowboy_req:chunk("streamed_handler\r\n", Req3),
|
|
||||||
timer:sleep(100),
|
|
||||||
cowboy_req:chunk("works fine!", Req3),
|
|
||||||
{ok, Req3, Opts}.
|
|
Loading…
Add table
Add a link
Reference in a new issue