Subject: bug#23750: 25.0.95; bug in url-retrieve or json.el

From: Dmitry Gutov <[email-masked]>
Date: Mon, 13 Jun 2016 18:02:13 +0300

On 06/12/2016 05:22 AM, Leo Liu wrote:

> ¹  https://github.com/ternjs/tern/issues/719

Investigation shows that the problem occurs when url-http-data is 
multibyte and (length url-http-data) differs from (length 
(string-as-unibyte url-http-data)), because we send a wrong value in 
Content-length.

Changing url-http-create-request like this will make the problem more 
obvious for anyone else that hits it, patch attached.

Stefan, did you have a particular situation in mind where this might be 
bad, when you wrote the FIXME?
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index 5832e92..f7ec640 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -278,14 +278,10 @@ url-http-create-request
           ;; We used to concat directly, but if one of the strings happens
           ;; to being multibyte (even if it only contains pure ASCII) then
           ;; every string gets converted with `string-MAKE-multibyte' which
-          ;; turns the 127-255 codes into things like latin-1 accented chars
-          ;; (it would work right if it used `string-TO-multibyte' instead).
+          ;; turns the 127-255 codes into things like latin-1 accented chars.
           ;; So to avoid the problem we force every string to be unibyte.
           (mapconcat
-           ;; FIXME: Instead of `string-AS-unibyte' we'd want
-           ;; `string-to-unibyte', so as to properly signal an error if one
-           ;; of the strings contains a multibyte char.
-           'string-as-unibyte
+           'string-to-unibyte
            (delq nil
             (list
              ;; The request