Bug in libghttp (with patch)



I'm not sure where to report this problem since there's no ghttp or
libghttp component in bugzilla.gnome.org and there doesn't appear to be
a ghttp mailing list.  Can someone here redirect this to the right
place?

The problem occurs when ghttp is used in a language that uses the comma
character as the decimal point. Ghttp sends the http version field as
"HTTP/1,1" instead of "HTTP/1.1" and Apache rejects this as a badly
formatted request.  This happens because the version is being printed as
a floating point number instead of as major/minor numbers separated by
the '.' character.  The attached patch will correct this problem.

This is in libghttp-1.0.9.

David



Index: http_req.c
===================================================================
RCS file: /cvs/libghttp/http_req.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 http_req.c
--- http_req.c	2 Jan 2003 09:43:57 -0000	1.1.1.1
+++ http_req.c	2 Jan 2003 09:49:46 -0000
@@ -108,6 +108,8 @@
   int         l_headers_len = 0;
   int         l_rv = 0;
   char       *l_content = NULL;
+  int         ver_major = 0;
+  int         ver_minor = 0;
 
   /* see if we need to jump into the function somewhere */
   if (a_conn->sync == HTTP_TRANS_ASYNC)
@@ -124,22 +126,25 @@
 						     (strlen(a_req->host) + 20) : 0));
   memset(l_request, 0, 30 + strlen(a_req->resource) + (a_conn->proxy_host ?
 						       (strlen(a_req->host) + 20) : 0));
+  /* split out major/minor version */
+  ver_major = (int)a_req->http_ver;
+  ver_minor = (int)((a_req->http_ver - ver_major) * 10);
   /* copy it into the buffer */
   if (a_conn->proxy_host)
     {
       l_request_len = sprintf(l_request,
-			      "%s %s HTTP/%01.1f\r\n",
+			      "%s %s HTTP/%d.%d\r\n",
 			      http_req_type_char[a_req->type],
 			      a_req->full_uri,
-			      a_req->http_ver);
+			      ver_major, ver_minor);
     }
   else
     {
       l_request_len = sprintf(l_request,
-			      "%s %s HTTP/%01.1f\r\n",
+			      "%s %s HTTP/%d.%d\r\n",
 			      http_req_type_char[a_req->type],
 			      a_req->resource,
-			      a_req->http_ver);
+			      ver_major, ver_minor);
     }
   /* set the request in the connection buffer */
   http_trans_append_data_to_buf(a_conn, l_request, l_request_len);

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]