Mark H Weaver <m...@netris.org> writes:

>> GET / HTTP/1.1
>> Content-Type: text/plain;charset=utf-8
>> Host: www.google.com
>> Connection: close
>
> I just applied a fix for this to the stable-2.0 branch in git.  In the
> meantime, the workaround is to explicitly pass a content-type header
> that specifies the charset, like this:
>
> (http-post "http://www.google.com/";
>            #:body ""
>            #:headers '((content-type text/plain (charset . "utf-8"))))

Sorry, this wasn't quite enough if the body is non-empty.  In order to
work around the bug, you also need to explicitly pass the content-length
header, like this:

  (use-modules (web client) (rnrs bytevectors))

  (let ((bv (string->utf8 "test")))
    (http-post "http://www.google.com/";
               #:body bv
               #:headers `((content-type text/plain (charset . "utf-8"))
                           (content-length . ,(bytevector-length bv)))))

More generally, when using (web client) for anything other than GET, you
must explicitly provide a content-type header with charset, and also a
content-length (if appropriate).

The bug is fixed in stable-2.0 git.

      Mark

Reply via email to