Hello, It's 1st day of May, a new month; I thought it would be better to summarize some issues of http-get. This post include 3 examples; working, half working and not working because of implementation of declare-uri-header!
Example 1 - working (use-modules (srfi srfi-8) ((web uri) #:select (string->uri)) ((web client) #:select (http-get))) (set-port-encoding! (current-output-port) "UTF-8") (fluid-set! %default-port-encoding "UTF-8") (receive (res-headers res-body) (http-get (string->uri "http://www.gnu.org/software/guile/")) (display res-body) (newline)) 1. receive is a macro to receive multi valued return of a certain procedure. http-get returns two values; headers of a web page and content of that. 2. (fluid-set! %default-port-encoding "UTF-8") is not needed in above case; codeset of http://www.gnu.org/software/guile/ is UTF-8 and above example only display it. I think it is a good habit to append this line if you want to use some other tools like html->sxml of guile-lib. 3. (set-port-encoding! (current-output-port) "UTF-8") is not needed in above case; codeset of http://www.gnu.org/software/guile/ is UTF-8 and written in plain english. I think it is a good habit to append this line if you want to display the content of web page. Example 2 - half working (receive (res-headers res-body) (http-get (string->uri "http://www.gnu.org/home.en.html")) (display res-body) (newline)) 1. http-get of current stable version, 2.0.5, of Guile does not support "Chunked Encoding." 2. You should apply patches of Ian Price's, http://lists.gnu.org/archive/html/guile-user/2011-11/msg00011.html , if this case. Example 3 - not working (receive (res-headers res-body) (http-get (string->uri "http://www.gnu.org/home.html") #:extra-headers (acons 'Accept-Language "en-US" '())) (display res-body) (newline)) 1. http://www.gnu.org/home.html replay with the contents of http://www.gnu.org/home.en.html . 2. Its Content-Location header is home.en.html, not http://www.gnu.org/home.en.html ; it is a relative URI, not absolute URI. There is no solution on current Guile if this case. Avoid this case and use a real web page like http://www.gnu.org/home.en.html .