Inets 4.0 and HTTP/1.1 "100 Continue" responses

Heinrich Venter heinrich@REDACTED
Thu Dec 2 18:59:12 CET 2004


It looks like I have managed to fix the problem with the 100 Continue
response lines

It's a bit messy and I certainly wouldn't recommend any one else use it
until the powers that be ok'd it.

I am only going to post the bits I changed

The idea is that if the "100 Continue" response is recognised, the Body
is re-parsed from scratch.  I am not sure if all the extra response
handling in the parsing case is neccesary.
I also don't know if the behavior of the header "expect=100-continue"
will stil be correct.

-]-[einrich


-- httpc_handler.erl

handle_response(State = #state{request = Request = #request{id = ID,
							    from =
Client},
			       session = Session, 
			       status_line = StatusLine,
			       headers = Headers, body = Body}) ->
    
    case lists:member(ID, State#state.canceled) of
	true ->
	    handle_pipeline(
	      State#state{canceled = lists:delete(ID, 
	
State#state.canceled)});
	false ->
	    case http_response:result({StatusLine, Headers, Body}, 
				       Request, Session) of
		{ok, ""} -> % redirect
                    handle_pipeline(State);
                %% Added this
                {ok, continue} ->
                    
                    {Module, Function, Args} = {http_response, parse,
	
[State#state.max_header_size]},
                    Data = State#state.body,
                    Method = (State#state.request)#request.method,
      		    case Module:Function([Data | Args]) of
                        {ok, Result} ->
                            handle_http_msg(Result, State); 
                        {_, whole_body, _} when Method == head ->
                            handle_response(State#state{body = <<>>}); 
                        NewMFA ->
 
http_transport:setopts(Session#tcp_session.scheme, 
 
Session#tcp_session.socket, 
                                                  [{active, once}]),
                            {noreply, State#state{mfa = NewMFA}}
                    end;
                    %% End addition
		{ok, Msg} ->
		    http_response:send(Client, Msg),
		    handle_pipeline(State);
		{stop, Msg} ->
		    http_response:send(Client, Msg),
		    {stop, normal, State}
	    end
    end.

-- http_response.erl

%%% RFC2616, Section 10.1.1
%%% Note:
%%% - Only act on the 100 status if the request included the
%%%   "Expect:100-continue" header, otherwise just ignore this response.
status_continue(Req = #http_request_h{expect="100-continue"}, Session)
->
    {_, Body} = Req#request.content,
    http_transport:send(Session#tcp_session.scheme, 
			Session#tcp_session.socket, Body),
    {ok, continue};

status_continue(_Req, _Session) ->
    error_logger:info_msg("Found Continue"),
    {ok, continue}.




Look 4 Help - Click here for more info
http://asp1.rocketseed.com/RocketSeed/mail/433a32353a3839353138393a33303639373a2d323a313933

 
http://asp1.rocketseed.com/RocketSeed/mail/433a32353a3839353138393a33303639373a2d323a313836
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20041202/ca571d95/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MTk2LjMwLjc5LjE1NQ==
Type: image/gif
Size: 19652 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20041202/ca571d95/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MTk2LjMwLjc5LjE1NQ==
Type: image/gif
Size: 556 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20041202/ca571d95/attachment-0001.gif>


More information about the erlang-questions mailing list