[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Working http-get example and still unsolved problem
From: |
Sunjoong Lee |
Subject: |
Working http-get example and still unsolved problem |
Date: |
Wed, 2 May 2012 00:20:28 +0900 |
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)
(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)
(display res-body)
(newline))
1. http-get of current stable version, 2.0.5, of Guile does not support "Chunked Encoding."
(receive (res-headers res-body)
#:extra-headers
(acons 'Accept-Language "en-US" '()))
(display res-body)
(newline))
- Working http-get example and still unsolved problem,
Sunjoong Lee <=