Branch: Tag:

2008-02-18

2008-02-18 18:51:24 by Martin Stjernholm <mast@lysator.liu.se>

Do the request line and header crunching once when HeaderParser->feed
returns it. This exploits the fact that HeaderParser->feed returns a
result only when it has gotten the complete header block.

This also fixes the bug with the changed scope of the line variable
which was introduced in rev 1.543.

Rev: server/protocols/http.pike:1.549

2:   // Modified by Francesco Chemolli to add throttling capabilities.   // Copyright © 1996 - 2004, Roxen IS.    - constant cvs_version = "$Id: http.pike,v 1.548 2008/02/18 18:39:58 mast Exp $"; + constant cvs_version = "$Id: http.pike,v 1.549 2008/02/18 18:51:24 mast Exp $";   // #define REQUEST_DEBUG   #define MAGIC_ERROR   
689:      private int parse_got( string new_data )   { -  { +  if (hp) {    string line;       TIMER_START(parse_got); -  if( !method ) -  { +     if (!hrtime)    hrtime = gethrtime(); -  +  {    array res;    if( mixed err = catch( res = hp->feed( new_data ) ) ) {   #ifdef DEBUG
787:    time = predef::time(1);    // if(!data) data = "";    //REQUEST_WERR(sprintf("HTTP: raw_url %O", raw_url)); -  } +        if(!remoteaddr)    {
804:    }       TIMER_START(parse_got_2_parse_headers); -  foreach( (array)request_headers, [string linename, array|string contents] ) +  foreach (request_headers; string linename; array|string contents)    {    if( arrayp(contents) ) contents = contents[0];    switch (linename)
884:    }    }    TIMER_END(parse_got_2_parse_headers); +  }       TIMER_START(parse_got_2_more_data);    if(misc->len)