[PATCH] libghttp and locale != C



Hi,

Here is a patch to solve a problem with http headers if locale are different
than C.

Christian

--- http_req.c.orig     Wed Apr 18 15:26:41 2001
+++ http_req.c  Wed Apr 18 15:28:48 2001
@@ -21,6 +21,7 @@
 
 #include <string.h>
 #include <stdlib.h>
+#include <locale.h>
 #include "http_req.h"
 #include "http_trans.h"
 #include "http_global.h"
@@ -127,19 +128,27 @@
   /* copy it into the buffer */
   if (a_conn->proxy_host)
     {
+      char *old_locale = strdup (setlocale (LC_NUMERIC, NULL));
+      setlocale (LC_NUMERIC, "C");
       l_request_len = sprintf(l_request,
                              "%s %s HTTP/%01.1f\r\n",
                              http_req_type_char[a_req->type],
                              a_req->full_uri,
                              a_req->http_ver);
+            setlocale (LC_NUMERIC, old_locale);
+            free (old_locale);
     }
   else
     {
+      char *old_locale = strdup (setlocale (LC_NUMERIC, NULL));
+      setlocale (LC_NUMERIC, "C");
       l_request_len = sprintf(l_request,
                              "%s %s HTTP/%01.1f\r\n",
                              http_req_type_char[a_req->type],
                              a_req->resource,
                              a_req->http_ver);
+            setlocale (LC_NUMERIC, old_locale);
+            free (old_locale);
     }
   /* set the request in the connection buffer */
   http_trans_append_data_to_buf(a_conn, l_request, l_request_len);




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