[Top][All Lists]

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

Re: A question about http-get of (web client)

From: Sunjoong Lee
Subject: Re: A question about http-get of (web client)
Date: Thu, 26 Apr 2012 21:50:48 +0900

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 "")
                        (acons 'Accept "text/html"
                               (acons 'Accept-Charset "ISO-8859-1"
                                      (acons 'Accept-Language "en-US"
  (display res-body)

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 "")
                        (acons 'Accept "text/plain" '()))))
  (display res-body)

Above code display this:
  <title>406 Not Acceptable</title>
  <h1>Not Acceptable</h1>
  <p>An appropriate representation of the requested resource /home.html could not be found on this server.</p>
  Available variants:
  <li><a href="" , 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 . "{\"\" 1 {type text/html} {language ar}}, {\"\" 1 {type text/html} {language bg}}, {\"\" 1 {type text/html} {language ca}}, {\"home.cs.html\" 1 {type text/html} {language cs}}, {\"\" 1 {type text/html} {language de}}, {\"home.el.html\" 1 {type text/html} {language el}}, {\"\" 1 {type text/html} {language es}}, {\"home.fa.html\" 1 {type text/html} {language fa}}, {\"\" 1 {type text/html} {language fr}}, {\"home.html\" 1 {type text/html} {language en}}, {\"\" 1 {type text/html} {language id}}, {\"\" 1 {type text/html} {language it}}, {\"home.ja.html\" 1 {type text/html} {language ja}}, {\"\" 1 {type text/html} {language kn}}, {\"home.ko.html\" 1 {type text/html} {language ko}}, {\"home.nb.html\" 1 {type text/html} {language nb}}, {\"\" 1 {type text/html} {language nl}}, {\"\" 1 {type text/html} {language pl}}, {\"\" 1 {type text/html} {language pt-br}}, {\"\" 1 {type text/html} {language ro}}, {\"\" 1 {type text/html} {language ru}}, {\"home.sq.html\" 1 {type text/html} {language sq}}, {\"\" 1 {type text/html} {language sr}}, {\"\" 1 {type text/html} {language tr}}, {\"\" 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>>

reply via email to

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