-const char jcc_rcs[] = "$Id: jcc.c,v 1.274 2009/07/19 11:19:50 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.275 2009/07/22 22:31:54 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
csp->content_type = 0;
csp->content_length = 0;
csp->expected_content_length = 0;
+ csp->expected_client_content_length = 0;
list_remove_all(csp->headers);
freez(csp->iob->buf);
memset(csp->iob, 0, sizeof(csp->iob));
-const char parsers_rcs[] = "$Id: parsers.c,v 1.204 2009/08/19 15:25:31 fabiankeil Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.205 2009/08/19 15:26:36 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/parsers.c,v $
static jb_err server_keep_alive(struct client_state *csp, char **header);
static jb_err server_proxy_connection(struct client_state *csp, char **header);
static jb_err client_keep_alive(struct client_state *csp, char **header);
+static jb_err client_save_content_length(struct client_state *csp, char **header);
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
static jb_err client_host_adder (struct client_state *csp);
{ "if-modified-since:", 18, client_if_modified_since },
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
{ "Keep-Alive:", 11, client_keep_alive },
+ { "Content-Length:", 15, client_save_content_length },
#else
{ "Keep-Alive:", 11, crumble },
#endif
return JB_ERR_OK;
}
+
+
+/*********************************************************************
+ *
+ * Function : client_save_content_length
+ *
+ * Description : Save the Content-Length sent by the client.
+ *
+ * XXX: Shares code with the server version
+ * that should be factored out.
+ *
+ * Parameters :
+ * 1 : csp = Current client state (buffers, headers, etc...)
+ * 2 : header = On input, pointer to header to modify.
+ * On output, pointer to the modified header, or NULL
+ * to remove the header. This function frees the
+ * original string if necessary.
+ *
+ * Returns : JB_ERR_OK on success, or
+ * JB_ERR_MEMORY on out-of-memory error.
+ *
+ *********************************************************************/
+static jb_err client_save_content_length(struct client_state *csp, char **header)
+{
+ unsigned long long content_length = 0;
+
+ assert(*(*header+14) == ':');
+
+#ifdef _WIN32
+ if (1 != sscanf(*header+14, ": %I64u", &content_length))
+#else
+ if (1 != sscanf(*header+14, ": %llu", &content_length))
+#endif
+ {
+ log_error(LOG_LEVEL_ERROR, "Crunching invalid header: %s", *header);
+ freez(*header);
+ }
+ else
+ {
+ log_error(LOG_LEVEL_CONNECT,
+ "Setting client content lenght %llu", content_length);
+ csp->expected_client_content_length = content_length;
+ }
+
+ return JB_ERR_OK;
+}
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
#ifndef PROJECT_H_INCLUDED
#define PROJECT_H_INCLUDED
/** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.147 2009/07/14 17:50:34 fabiankeil Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.148 2009/07/18 12:20:05 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/project.h,v $
unsigned long long content_length;
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
+ /* XXX: is this the right location? */
+
/** Expected length of content after which we
* should stop reading from the server socket.
*/
- /* XXX: is this the right location? */
unsigned long long expected_content_length;
+
+ /** Expected length of content after which we
+ * should stop reading from the client socket.
+ */
+ unsigned long long expected_client_content_length;
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
#ifdef FEATURE_TRUST