Inets 4.0 and HTTP/1.1 "100 Continue" responses

Heinrich Venter <>
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.


-- httpc_handler.erl

handle_response(State = #state{request = Request = #request{id = ID,
							    from =
			       session = Session, 
			       status_line = StatusLine,
			       headers = Headers, body = Body}) ->
    case lists:member(ID, State#state.canceled) of
	true ->
	      State#state{canceled = lists:delete(ID, 
	false ->
	    case http_response:result({StatusLine, Headers, Body}, 
				       Request, Session) of
		{ok, ""} -> % redirect
                %% Added this
                {ok, continue} ->
                    {Module, Function, Args} = {http_response, parse,
                    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 ->
                                                  [{active, once}]),
                            {noreply, State#state{mfa = NewMFA}}
                    %% End addition
		{ok, Msg} ->
		    http_response:send(Client, Msg),
		{stop, Msg} ->
		    http_response:send(Client, Msg),
		    {stop, normal, State}

-- 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,
			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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MTk2LjMwLjc5LjE1NQ==
Type: image/gif
Size: 19652 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MTk2LjMwLjc5LjE1NQ==
Type: image/gif
Size: 556 bytes
Desc: not available
URL: <>

More information about the erlang-questions mailing list