From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sunjoong Lee Newsgroups: gmane.lisp.guile.user Subject: Re: A question about http-get of (web client) Date: Fri, 27 Apr 2012 23:20:01 +0900 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0016e6daa63713ecee04bea9cec6 X-Trace: dough.gmane.org 1335536449 5088 80.91.229.3 (27 Apr 2012 14:20:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 27 Apr 2012 14:20:49 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Apr 27 16:20:48 2012 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SNm2L-0004vw-EH for guile-user@m.gmane.org; Fri, 27 Apr 2012 16:20:41 +0200 Original-Received: from localhost ([::1]:57904 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SNm2K-0002Ed-Ow for guile-user@m.gmane.org; Fri, 27 Apr 2012 10:20:40 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:48246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SNm2A-0002Dz-NX for guile-user@gnu.org; Fri, 27 Apr 2012 10:20:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SNm25-0007lE-Fs for guile-user@gnu.org; Fri, 27 Apr 2012 10:20:30 -0400 Original-Received: from mail-wi0-f177.google.com ([209.85.212.177]:64121) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SNm25-0007kz-3l for guile-user@gnu.org; Fri, 27 Apr 2012 10:20:25 -0400 Original-Received: by wibhj13 with SMTP id hj13so499410wib.12 for ; Fri, 27 Apr 2012 07:20:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=tEjB1ewdn0t5iBKWqQnxGlt8ieThqNfmgmPGyY6nGHw=; b=NWW2MBcUAOfaZDfB5QA28cUlDyMreXcx/wloY6azrUJCSgAXCSYMXXcNi2OPonEshO 64i0WkMOU1FYakLFuQ7kMHzl+auhRFEYBIkbrHjXpzABwgbnymxeFxzKblH3c4hCiTsb Tj4WfrvtsF6I0zMZZhDeN4GJNPzTrNDcPgoYUxc1IgtGrPPrsHchoKBrVvwlL9Wpf4yi wrQEVGEUhC3wjH3mbFfZ3yN0qMkUQUmwJIdLevxlzWzqYmKREzCHQ9nkFv90HP6XIQ5z HPDe9ZjVkaFhKVovTnM04GNEozZalhdoU9Pm0nNVw0+tlFjI51xdKV/J/El4bCzET9+q R+Wg== Original-Received: by 10.216.142.226 with SMTP id i76mr5986600wej.28.1335536423005; Fri, 27 Apr 2012 07:20:23 -0700 (PDT) Original-Received: by 10.223.93.206 with HTTP; Fri, 27 Apr 2012 07:20:01 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.212.177 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9408 Archived-At: --0016e6daa63713ecee04bea9cec6 Content-Type: text/plain; charset=UTF-8 I think I found the cause of the error; the error was in declare-uri-header! That was not a encoding problem. http://www.gnu.org/home.html will send Content-Location header and it is home.en.html if your Accept-Language is en-US. Yes!! This is a relativeURI. Location is absolute URI but Content-Location and Referer may be relative URI or absolute URI. Current declare-uri-header! can do only absolute URI because string->uri returns false value whenever not absolute URI!! 2012/4/26 Sunjoong Lee > > (use-modules ((srfi srfi-11) #:select (let-values)) > ((web uri) #:select (string->uri)) > ((web client) #:select (http-get))) > (let-values (((res-headers res-body) > (http-get (string->uri "http://www.gnu.org/home.html") > #:extra-headers > (acons 'Accept "text/html" > (acons 'Accept-Charset "ISO-8859-1" > (acons 'Accept-Language "en-US" > '())))))) > (display res-body) > (newline)) > > Above code makes an error: > ... > In web/response.scm: > 187: 2 [read-response #] > In web/http.scm: > 218: 1 [lp ((server . "Apache/2.2.14") (date . #))] > 184: 0 [read-header #] > --0016e6daa63713ecee04bea9cec6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I think I found the cause of the error; the erro= r was in declare-uri-header! That was not a encoding problem.

http://www.gnu.org/home.html will send=C2=A0Conte= nt-Location header and it is home.en.html if your=C2=A0Accept-Language is e= n-US. Yes!! This is a=C2=A0relativeURI.

Location is= =C2=A0absolute URI but=C2=A0Content-Location and Referer may be=C2=A0relati= ve URI or=C2=A0absolute URI. Current=C2=A0declare-uri-header! can do only= =C2=A0absolute URI because=C2=A0string->uri returns false value whenever= not=C2=A0absolute URI!!

2012/4/26 Sunjoon= g Lee <sunjoong@gmail.com>
(use-modules ((srfi srfi-11) #:select (let-values))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0((web uri) =C2=A0 =C2=A0 =C2=A0#:select (string->uri))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= ((web client) =C2=A0 #:select (http-get)))
(let-values (((res-headers res-body)
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (http-get (string->uri = "http://www= .gnu.org/home.html")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #:extra-headers
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 (acons 'Accept "text/html"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(acons 'Accept-C= harset "ISO-8859-1"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (acons 'Accept-Language "en-US"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0'()))))))
=C2=A0 (display res-body)
=C2=A0 (newline))=

Above code makes an error:
=C2=A0 ...
=C2=A0 In web/response.scm:
=C2=A0 =C2=A0187: 2 [read-response #<input-output: socket 5&= gt;]
=C2=A0 In web/http.scm:
=C2=A0 =C2=A0218: 1 [lp ((server . "Apache/2.2.14&qu= ot;) (date . #))]
=C2=A0 =C2=A0184: 0 [read-header #<input-outp= ut: socket 5>]
--0016e6daa63713ecee04bea9cec6--