Branch: Tag:

2005-04-01

2005-04-01 16:10:34 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Attept to fix support for chained requests.

Rev: server/protocols/http.pike:1.470

2:   // Modified by Francesco Chemolli to add throttling capabilities.   // Copyright © 1996 - 2004, Roxen IS.    - constant cvs_version = "$Id: http.pike,v 1.469 2005/03/31 09:53:13 grubba Exp $"; + constant cvs_version = "$Id: http.pike,v 1.470 2005/04/01 16:10:34 grubba Exp $";   // #define REQUEST_DEBUG   #define MAGIC_ERROR   
319:    }   }    + int(0..1) my_fd_busy; + int(0..1) pipe_pending; +    void start_sender( )   { -  +  if (my_fd_busy) { +  // We're waiting for the previous request to finish. +  pipe_pending = 1; + #ifdef CONNECTION_DEBUG +  werror("HTTP: Pipe pending.\n"); + #endif +  return; +  }    if (pipe)    {    MARK_FD("HTTP really handled, piping response");
340:    }   }    + void my_fd_released() + { +  my_fd_busy = 0; + #ifdef CONNECTION_DEBUG +  werror("HTTP: Fd released.\n"); + #endif +  if (pipe_pending) { +  start_sender(); +  } + } +    string scan_for_query( string f )   {    query=0;
389: Inside #if defined(OLD_RXML_CONFIG)
   };       void do_send_reply( string what, string url ) { +  // FIXME: Delayed chaining! my_fd_busy.    CHECK_FD_SAFE_USE;    url = url_base() + url[1..];    my_fd->set_blocking();
668:    method = "GET"; // 0.9 only supports get.    else    { +  // FIXME: my_fd_busy.    my_fd->write("PONG\r\n");    TIMER_END(parse_got_2);    return 2;
867:    if (!misc->host) {    // RFC 2616 requires this behaviour.    REQUEST_WERR("HTTP: HTTP/1.1 request without a host header."); +  // FIXME: my_fd_busy.    my_fd->write((prot||"HTTP/1.1") +    " 400 Bad request (missing host header).\r\n"    "Content-Length: 0\r\n"
943:    o->client_var = client_var;    o->host = host;    o->conf = conf; -  o->pipe = pipe; +  o->my_fd_busy = !!pipe; +  o->pipe = 0;    o->connection_misc = connection_misc;    o->kept_alive = kept_alive+1;    object fd = my_fd;    my_fd=0;    pipe = 0; -  +  chained_to = o;    call_out (o->chain, 0, fd,port_obj,leftovers);    disconnect();    return;
1340:    return !!cache;   }    + static object(this_program) chained_to; +  + // Paranoia. + static void destroy() + { +  if (chained_to) { +  werror("HTTP: Still chained in destroy!\n"); +  call_out(chained_to->my_fd_released, 0); +  chained_to = 0; +  } + } +    void do_log( int|void fsent )   {   #ifdef CONNECTION_DEBUG    werror ("HTTP: Response sent ============================================\n");   #endif    MARK_FD("HTTP logging"); // fd can be closed here -  +  if (chained_to) { +  // Release the other sender. +  call_out(chained_to->my_fd_released, 0); +  chained_to = 0; +  }    TIMER_START(do_log);    if(conf)    {
1605:    // FIXME: Only send once?    if (clientprot == "HTTP/1.1" && request_headers->expect &&    (request_headers->expect == "100-continue" || -  has_value(request_headers->expect, "100-continue" ))) +  has_value(request_headers->expect, "100-continue" )) && +  !my_fd_busy)    my_fd->write("HTTP/1.1 100 Continue\r\n");   }   
1966:    }    else    { -  if( strlen( head_string ) < (HTTP_BLOCKING_SIZE_THRESHOLD)) +  if( !kept_alive && +  (strlen(head_string) < (HTTP_BLOCKING_SIZE_THRESHOLD)))    {   #ifdef CONNECTION_DEBUG    werror ("HTTP: Response =================================================\n"