From: Sunjoong Lee <sunjoong@gmail.com>
To: guile-user@gnu.org
Subject: Re: A question about http-get of (web client)
Date: Thu, 26 Apr 2012 21:50:48 +0900 [thread overview]
Message-ID: <CAK93xhqy79WKXpaOCBtoH0jYYB6oywVufh=DmqK5MazsS4_W+Q@mail.gmail.com> (raw)
In-Reply-To: <CAK93xhrqrSnOndtZUzpitmQM-e0k4XnKZgHyUb2W5kwqAkf1=w@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3723 bytes --]
I suspect "ISO-8859-1" make a problem. open-socket-for-uri of (web client)
sets encoding of port to "ISO-8859-1". read-response of (web response)
also sets encoding of port to "ISO-8859-1".
(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 #<input-output: socket 5>]
In web/http.scm:
218: 1 [lp ((server . "Apache/2.2.14") (date . #))]
184: 0 [read-header #<input-output: socket 5>]
Same error after changing above "ISO-8859-1" to "utf-8" of course; It's
meaningless.
(let-values (((res-headers res-body)
(http-get (string->uri "http://www.gnu.org/home.html")
#:extra-headers
(acons 'Accept "text/plain" '()))))
(display res-body)
(newline))
Above code display this:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>406 Not Acceptable</title>
</head><body>
<h1>Not Acceptable</h1>
<p>An appropriate representation of the requested resource /home.html
could not be found on this server.</p>
Available variants:
<ul>
<li><a href="home.ar.html">home.ar.html</a> , type text/html, language
ar</li>
...
406 Not Acceptable? I think 'Accept "text/html" and 'Accept-Language
"en-US" will be need. But, "text/html" makes a above error!!
After changing (display res-body) to (display res-headers):
#<<response> version: (1 . 1) code: 406 reason-phrase: "Not Acceptable"
headers: ((date . #<date nanosecond: 0 second: 52 minute: 34 hour: 12 day:
26 month: 4 year: 2012 zone-offset: 0>) (server . "Apache/2.2.14")
(alternates . "{\"home.ar.html\" 1 {type text/html} {language ar}},
{\"home.bg.html\" 1 {type text/html} {language bg}}, {\"home.ca.html\" 1
{type text/html} {language ca}}, {\"home.cs.html\" 1 {type text/html}
{language cs}}, {\"home.de.html\" 1 {type text/html} {language de}},
{\"home.el.html\" 1 {type text/html} {language el}}, {\"home.es.html\" 1
{type text/html} {language es}}, {\"home.fa.html\" 1 {type text/html}
{language fa}}, {\"home.fr.html\" 1 {type text/html} {language fr}},
{\"home.html\" 1 {type text/html} {language en}}, {\"home.id.html\" 1 {type
text/html} {language id}}, {\"home.it.html\" 1 {type text/html} {language
it}}, {\"home.ja.html\" 1 {type text/html} {language ja}},
{\"home.kn.html\" 1 {type text/html} {language kn}}, {\"home.ko.html\" 1
{type text/html} {language ko}}, {\"home.nb.html\" 1 {type text/html}
{language nb}}, {\"home.nl.html\" 1 {type text/html} {language nl}},
{\"home.pl.html\" 1 {type text/html} {language pl}}, {\"home.pt-br.html\" 1
{type text/html} {language pt-br}}, {\"home.ro.html\" 1 {type text/html}
{language ro}}, {\"home.ru.html\" 1 {type text/html} {language ru}},
{\"home.sq.html\" 1 {type text/html} {language sq}}, {\"home.sr.html\" 1
{type text/html} {language sr}}, {\"home.tr.html\" 1 {type text/html}
{language tr}}, {\"home.uk.html\" 1 {type text/html} {language uk}},
{\"home.zh-cn.html\" 1 {type text/html} {language zh-cn}}") (vary negotiate
accept-language accept-encoding) (tcn . "list") (content-length . 2425)
(connection close) (content-type text/html (charset . "iso-8859-1"))) port:
#<closed: file 0>>
[-- Attachment #2: Type: text/html, Size: 5984 bytes --]
next prev parent reply other threads:[~2012-04-26 12:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-26 1:15 A question about http-get of (web client) Sunjoong Lee
2012-04-26 12:50 ` Sunjoong Lee [this message]
2012-04-27 14:20 ` Sunjoong Lee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAK93xhqy79WKXpaOCBtoH0jYYB6oywVufh=DmqK5MazsS4_W+Q@mail.gmail.com' \
--to=sunjoong@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).