0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Remove or fix a small number of todo comments

One had the todo text fixed, another had the task to do done.
This commit is contained in:
Loïc Hoguin 2017-02-05 20:45:36 +01:00
parent 1504c60c89
commit 80f8cda7ff
No known key found for this signature in database
GPG key ID: 71366FF21851DF03
4 changed files with 4 additions and 28 deletions

View file

@ -111,9 +111,6 @@
%% Children which are in the process of shutting down. %% Children which are in the process of shutting down.
children = [] :: [{pid(), cowboy_stream:streamid(), timeout()}] children = [] :: [{pid(), cowboy_stream:streamid(), timeout()}]
%% @todo Automatic compression. (compress option?)
%% @todo onresponse? Equivalent using streams.
}). }).
-include_lib("cowlib/include/cow_inline.hrl"). -include_lib("cowlib/include/cow_inline.hrl").
@ -246,8 +243,6 @@ parse(Buffer, State=#state{in_state=#ps_body{}}) ->
%% @todo We do not want to get the body automatically if the request doesn't ask for it. %% @todo We do not want to get the body automatically if the request doesn't ask for it.
%% We may want to get bodies that are below a threshold without waiting, and buffer them %% We may want to get bodies that are below a threshold without waiting, and buffer them
%% until the request asks, though. %% until the request asks, though.
%% @todo Transfer-decoding must be done here.
after_parse(parse_body(Buffer, State)). after_parse(parse_body(Buffer, State)).
%% @todo Don't parse if body is finished but request isn't. Let's not parallelize for now. %% @todo Don't parse if body is finished but request isn't. Let's not parallelize for now.
@ -415,7 +410,6 @@ skip_uri_fragment(<< C, Rest/bits >>, State, M, P, Q) ->
_ -> skip_uri_fragment(Rest, State, M, P, Q) _ -> skip_uri_fragment(Rest, State, M, P, Q)
end. end.
%% @todo Calls to parse_header should update the state.
parse_version(<< "HTTP/1.1\r\n", Rest/bits >>, State, M, P, Q) -> parse_version(<< "HTTP/1.1\r\n", Rest/bits >>, State, M, P, Q) ->
parse_headers(Rest, State, M, P, Q, 'HTTP/1.1'); parse_headers(Rest, State, M, P, Q, 'HTTP/1.1');
parse_version(<< "HTTP/1.0\r\n", Rest/bits >>, State, M, P, Q) -> parse_version(<< "HTTP/1.0\r\n", Rest/bits >>, State, M, P, Q) ->
@ -431,7 +425,6 @@ parse_version(_, State, _, _, _) ->
'Unsupported HTTP version. (RFC7230 2.6)'}). 'Unsupported HTTP version. (RFC7230 2.6)'}).
parse_headers(Rest, State, M, P, Q, V) -> parse_headers(Rest, State, M, P, Q, V) ->
%% @todo Figure out the parse states.
parse_header(Rest, State#state{in_state=#ps_header{ parse_header(Rest, State#state{in_state=#ps_header{
method=M, path=P, qs=Q, version=V}}, #{}). method=M, path=P, qs=Q, version=V}}, #{}).
@ -606,21 +599,15 @@ request(Buffer, State0=#state{ref=Ref, transport=Transport, peer=Peer, in_stream
scheme => Scheme, scheme => Scheme,
host => Host, host => Host,
port => Port, port => Port,
%% @todo The path component needs to be normalized.
%% @todo So the path component needs to be normalized.
path => Path, path => Path,
qs => Qs, qs => Qs,
version => Version, version => Version,
%% We are transparently taking care of transfer-encodings so %% We are transparently taking care of transfer-encodings so
%% the user code has no need to know about it. %% the user code has no need to know about it.
headers => maps:remove(<<"transfer-encoding">>, Headers), headers => maps:remove(<<"transfer-encoding">>, Headers),
has_body => HasBody, has_body => HasBody,
body_length => BodyLength body_length => BodyLength
%% @todo multipart? keep state separate
%% meta values (cowboy_websocket, cowboy_rest)
}, },
case is_http2_upgrade(Headers, Version) of case is_http2_upgrade(Headers, Version) of
false -> false ->
@ -679,14 +666,12 @@ http2_upgrade(State=#state{parent=Parent, ref=Ref, socket=Socket, transport=Tran
%% However if the client sent a body, we need to read the body in full %% However if the client sent a body, we need to read the body in full
%% and if we can't do that, return a 413 response. Some options are in order. %% and if we can't do that, return a 413 response. Some options are in order.
%% Always half-closed stream coming from this side. %% Always half-closed stream coming from this side.
try cow_http_hd:parse_http2_settings(HTTP2Settings) of try cow_http_hd:parse_http2_settings(HTTP2Settings) of
Settings -> Settings ->
Transport:send(Socket, cow_http:response(101, 'HTTP/1.1', maps:to_list(#{ Transport:send(Socket, cow_http:response(101, 'HTTP/1.1', maps:to_list(#{
<<"connection">> => <<"Upgrade">>, <<"connection">> => <<"Upgrade">>,
<<"upgrade">> => <<"h2c">> <<"upgrade">> => <<"h2c">>
}))), }))),
%% @todo Possibly redirect the request if it was https. %% @todo Possibly redirect the request if it was https.
_ = cancel_request_timeout(State), _ = cancel_request_timeout(State),
cowboy_http2:init(Parent, Ref, Socket, Transport, Opts, Peer, Buffer, Settings, Req) cowboy_http2:init(Parent, Ref, Socket, Transport, Opts, Peer, Buffer, Settings, Req)
@ -1030,7 +1015,7 @@ error_terminate(StatusCode, State=#state{socket=Socket, transport=Transport}, Re
-spec terminate(_, _) -> no_return(). -spec terminate(_, _) -> no_return().
terminate(_State, _Reason) -> terminate(_State, _Reason) ->
exit(normal). %% @todo exit(normal). %% @todo We probably don't want to exit normal on errors.
%% System callbacks. %% System callbacks.

View file

@ -36,9 +36,6 @@
-type stream() :: #stream{}. -type stream() :: #stream{}.
%% @todo priority: if we receive a message for a stream, do a selective receive
%% to get all messages in the mailbox and prioritize them. (later)
-record(state, { -record(state, {
parent = undefined :: pid(), parent = undefined :: pid(),
ref :: ranch:ref(), ref :: ranch:ref(),
@ -569,7 +566,7 @@ stream_init(State0=#state{ref=Ref, socket=Socket, transport=Transport, peer=Peer
cow_http_hd:parse_content_length(BinLength) cow_http_hd:parse_content_length(BinLength)
catch _:_ -> catch _:_ ->
terminate(State0, {stream_error, StreamID, protocol_error, terminate(State0, {stream_error, StreamID, protocol_error,
''}) %% @todo 'The content-length header is invalid. (RFC7230 3.3.2)'})
%% @todo Err should terminate here... %% @todo Err should terminate here...
end, end,
Length; Length;
@ -591,12 +588,8 @@ stream_init(State0=#state{ref=Ref, socket=Socket, transport=Transport, peer=Peer
qs => Qs, qs => Qs,
version => 'HTTP/2', version => 'HTTP/2',
headers => Headers, headers => Headers,
has_body => IsFin =:= nofin, has_body => IsFin =:= nofin,
body_length => BodyLength body_length => BodyLength
%% @todo multipart? keep state separate
%% meta values (cowboy_websocket, cowboy_rest)
}, },
stream_handler_init(State, StreamID, IsFin, Req); stream_handler_init(State, StreamID, IsFin, Req);
{_, DecodeState} -> {_, DecodeState} ->

View file

@ -65,7 +65,6 @@
-export([set_resp_header/3]). -export([set_resp_header/3]).
-export([set_resp_headers/2]). -export([set_resp_headers/2]).
-export([has_resp_header/2]). -export([has_resp_header/2]).
%% @todo resp_header
-export([delete_resp_header/2]). -export([delete_resp_header/2]).
-export([set_resp_body/2]). -export([set_resp_body/2]).
%% @todo set_resp_body/3 with a ContentType or even Headers argument, to set content headers. %% @todo set_resp_body/3 with a ContentType or even Headers argument, to set content headers.
@ -75,7 +74,7 @@
-export([reply/4]). -export([reply/4]).
-export([stream_reply/2]). -export([stream_reply/2]).
-export([stream_reply/3]). -export([stream_reply/3]).
%% @todo stream_reply/2 (nofin) %% @todo stream_body/2 (nofin)
-export([stream_body/3]). -export([stream_body/3]).
%% @todo stream_event/2,3 %% @todo stream_event/2,3
-export([push/3]). -export([push/3]).

View file

@ -116,7 +116,6 @@ info(_StreamID, SwitchProtocol = {switch_protocol, _, _, _}, State) ->
{[SwitchProtocol], State}; {[SwitchProtocol], State};
%% Stray message. %% Stray message.
info(_StreamID, _Info, State) -> info(_StreamID, _Info, State) ->
%% @todo Error report.
%% @todo Cleanup if no reply was sent when stream ends. %% @todo Cleanup if no reply was sent when stream ends.
{[], State}. {[], State}.