guile-user
[Top][All Lists]
Advanced

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

Re: is (web client) ready for use even for the simplest task?


From: Mark H Weaver
Subject: Re: is (web client) ready for use even for the simplest task?
Date: Tue, 10 Sep 2013 06:01:52 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Mark H Weaver <address@hidden> 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

[Prev in Thread] Current Thread [Next in Thread]