current jcc.c,1.449,1.450

Fabian Keil <[email protected]> Sat, 24 Dec 2016 16:01:34 +0000
Newsgroups gmane.comp.web.privoxy.cvs
Message-ID <[email protected]>
Update of /cvsroot/ijbswa/current
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv25164

Modified Files:
	jcc.c 
Log Message:
Factor send_http_request() out of chat()


Index: jcc.c
===================================================================
RCS file: /cvsroot/ijbswa/current/jcc.c,v
retrieving revision 1.449
retrieving revision 1.450
diff -C2 -d -r1.449 -r1.450
*** jcc.c	24 Dec 2016 16:00:49 -0000	1.449
--- jcc.c	24 Dec 2016 16:01:32 -0000	1.450
***************
*** 1891,1894 ****
--- 1891,1945 ----
  /*********************************************************************
   *
+  * Function    : send_http_request
+  *
+  * Description : Sends the HTTP headers from the client request
+  *               and all the body data that has already been received.
+  *
+  * Parameters  :
+  *          1  :  csp = Current client state (buffers, headers, etc...)
+  *
+  * Returns     :  0 on success, anything else is na error.
+  *
+  *********************************************************************/
+ static int send_http_request(struct client_state *csp)
+ {
+    char *hdr;
+    int write_failure;
+ 
+    hdr = list_to_text(csp->headers);
+    if (hdr == NULL)
+    {
+       /* FIXME Should handle error properly */
+       log_error(LOG_LEVEL_FATAL, "Out of memory parsing client header");
+    }
+    list_remove_all(csp->headers);
+ 
+    /*
+     * Write the client's (modified) header to the server
+     * (along with anything else that may be in the buffer)
+     */
+    write_failure = 0 != write_socket(csp->server_connection.sfd, hdr, strlen(hdr));
+    freez(hdr);
+ 
+    if (write_failure)
+    {
+       log_error(LOG_LEVEL_CONNECT, "Failed sending request headers to: %s: %E",
+          csp->http->hostport);
+    }
+    else if (((csp->flags & CSP_FLAG_PIPELINED_REQUEST_WAITING) == 0)
+       && (flush_socket(csp->server_connection.sfd, csp->client_iob) < 0))
+    {
+       write_failure = 1;
+       log_error(LOG_LEVEL_CONNECT, "Failed sending request body to: %s: %E",
+          csp->http->hostport);
+    }
+ 
+    return write_failure;
+ 
+ }
+ 
+ 
+ /*********************************************************************
+  *
   * Function    :  handle_established_connection
   *
***************
*** 2652,2656 ****
  {
     char buf[BUFFER_SIZE];
-    char *hdr;
     const struct forward_spec *fwd;
     struct http_request *http;
--- 2703,2706 ----
***************
*** 2851,2884 ****
     else if (fwd->forward_host || (http->ssl == 0))
     {
!       int write_failure;
!       hdr = list_to_text(csp->headers);
!       if (hdr == NULL)
!       {
!          /* FIXME Should handle error properly */
!          log_error(LOG_LEVEL_FATAL, "Out of memory parsing client header");
!       }
!       list_remove_all(csp->headers);
! 
!       /*
!        * Write the client's (modified) header to the server
!        * (along with anything else that may be in the buffer)
!        */
!       write_failure = 0 != write_socket(csp->server_connection.sfd, hdr, strlen(hdr));
!       freez(hdr);
! 
!       if (write_failure)
!       {
!          log_error(LOG_LEVEL_CONNECT,
!             "Failed sending request headers to: %s: %E", http->hostport);
!       }
!       else if (((csp->flags & CSP_FLAG_PIPELINED_REQUEST_WAITING) == 0)
!          && (flush_socket(csp->server_connection.sfd, csp->client_iob) < 0))
!       {
!          write_failure = 1;
!          log_error(LOG_LEVEL_CONNECT,
!             "Failed sending request body to: %s: %E", http->hostport);
!       }
! 
!       if (write_failure)
        {
           rsp = error_response(csp, "connect-failed");
--- 2901,2905 ----
     else if (fwd->forward_host || (http->ssl == 0))
     {
!       if (send_http_request(csp))
        {
           rsp = error_response(csp, "connect-failed");


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel