<div class="gmail_quote"><br>On Sun, Dec 13, 2009 at 5:20 AM, ccwu <span dir="ltr"><<a href="mailto:ccwu660601@gmail.com">ccwu660601@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Ok, now I know the answer.<br>
I've thought that (http->get url) returns an input-port, but it<br>
returns an http-client-response instead.<br><br></blockquote></div><br>Correct. http-get returns http-client-response, which wraps over both the headers and a pure input-port (without the headers). You can use http-client-response-headers to retrieve the headers, which are key/value pairs, and you can retrieve the response as an input port to retrieve and manipulate the body. Use close-input-port when you are done so the TCP connection can be released. <br>
<br>Below is an example repl session. Cheers,<br>yc<br><br>Welcome to DrScheme, version 4.2.1 [3m].<br>Language: Module; memory limit: 128 megabytes.<br>> (require (planet bzlib/http))<br>> (define response (http-get "<a href="http://www.google.com/">http://www.google.com/</a>"))<br>
|(reader #<input-port:<a href="http://www.google.com">www.google.com</a>>)<br>|"HTTP/1.0 200 OK"<br>> response<br>#<http-client-response><br>> (http-client-response-headers response)<br>(("X-XSS-Protection" . "0")<br>
("Server" . "gws")<br> ("Set-Cookie"<br> .<br> "NID=29=UrP_GBX8LIjMuHubAxlXD5Uzo2m1tz5GqvJaZqq8tLPbo5kkcg56DT5BgeKLtN3WyYqbcMSJwzZWQC5T8ONvj68FSJRf2ehC8SXyl63pDlgLuP5lMpElmcCRKbsCDn_i; expires=Mon, 14-Jun-2010 17:47:24 GMT; path=/; domain=.<a href="http://google.com">google.com</a>; HttpOnly")<br>
("Set-Cookie"<br> .<br> "PREF=ID=1453ea3d4dd38bd4:TM=1260726444:LM=1260726444:S=Gdsq2rwddhYWBX1N; expires=Tue, 13-Dec-2011 17:47:24 GMT; path=/; domain=.<a href="http://google.com">google.com</a>")<br>
("Content-Type" . "text/html; charset=ISO-8859-1")<br> ("Cache-Control" . "private, max-age=0")<br> ("Expires" . "-1")<br> ("Date" . "Sun, 13 Dec 2009 17:47:24 GMT"))<br>
> (read-bytes 2048 response)<br>#"<!doctype html><html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\"><title>Google</title><script>window.google={kEI:\"rCglS_TNGZrkpgSZt-XeCQ\",kEXPI:\"17259,22452,23061,23129,23179\",kCSI:{e:\"17259,22452,23061,23129,23179\",ei:\"rCglS_TNGZrkpgSZt-XeCQ\"},kHL:\"en\",time:function(){return(new Date).getTime()},log:function(b,d,c){var a=new Image,e=google,g=<a href="http://e.lc">e.lc</a>,f=<a href="http://e.li">e.li</a>;a.onerror=(a.onload=(a.onabort=function(){delete g[f]}));g[f]=a;c=c||\"/gen_204?atyp=i&ct=\"+b+\"&cad=\"+d+\"&zx=\"+google.time();a.src=c;<a href="http://e.li">e.li</a>=f+1},lc:[],li:0};\<a href="http://nwindow.google.sn">nwindow.google.sn</a>=\"webhp\";window.google.timers={load:{t:{start:(new Date).getTime()}}};try{}catch(u){}window.google.jsrt_kill=1;\nvar _gjwl=location;function _gjuc(){var e=_gjwl.href.indexOf(\"#\");if(e>=0){var a=_gjwl.href.substring(e);if(a.indexOf(\"&q=\")>0||a.indexOf(\"#q=\")>=0){a=a.substring(1);if(a.indexOf(\"#\")==-1){for(var c=0;c<a.length;){var d=c;if(a.charAt(d)==\"&\")++d;var b=a.indexOf(\"&\",d);if(b==-1)b=a.length;var f=a.substring(d,b);if(f.indexOf(\"fp=\")==0){a=a.substring(0,c)+a.substring(b,a.length);b=c}else if(f==\"cad=h\")return 0;c=b}_gjwl.href=\"/search?\"+a+\"&cad=h\";return 1}}}return 0}function _gjp(){!(window._gjwl.hash&&\nwindow._gjuc())&&setTimeout(_gjp,500)};\nwindow._gjp && _gjp()</script><style>td{line-height:.8em;}.gac_m td{line-height:17px;}form{margin-bottom:20px;}body,td,a,p,.h{font-family:arial,sans-serif}.h{color:#36c;font-size:20px}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}em{font-weight:bold;font-style:normal}.lst{font:17px arial,sans-serif;margin-bottom:.2em;vertical-align:bottom;}input{font-family:inherit}.lsb,.gac_sb{font-size:15px;height:1.85em!important;margin:.2em;}#gbar{float:left;height:22px}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#gbs,.gbm{background:#fff;left:0;position:absolute;text-align:left;visibility:hidden;z-index:1000}.gbm{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:1001}#guser{padding-bottom:7px !important;text-align:right}#gbar,#guser{font-siz"<br>
> (close-input-port response)<br>> <br><br><br><br>