# HG changeset patch # User Nobuyasu Oshiro # Date 1338218571 -32400 # Node ID bc647a5f0421d5d84dc2ad033e8a2d0a6a4fec38 # Parent 0335cdd081d06f076f33bdc3f90a3c96fe2eb5e6 modify HttpRequest.k diff -r 0335cdd081d0 -r bc647a5f0421 http/HttpRequest.k --- a/http/HttpRequest.k Mon May 28 23:56:15 2012 +0900 +++ b/http/HttpRequest.k Tue May 29 00:22:51 2012 +0900 @@ -35,7 +35,7 @@ } void printRequestProperty() { - foreach (String key in property.keys()) + for (String key : property.keys()) OUT << key +": " + property[key] << EOL; } diff -r 0335cdd081d0 -r bc647a5f0421 http/httpRequestTest.k --- a/http/httpRequestTest.k Mon May 28 23:56:15 2012 +0900 +++ b/http/httpRequestTest.k Tue May 29 00:22:51 2012 +0900 @@ -1,19 +1,18 @@ include "HttpRequest.k" - - -void printResponse(InputStream in) { - print("print Response"); +String getResponse(InputStream in) { + String str = ""; while ( !in.isClosed() ) { String ret = in.readLine(); - OUT << ret << EOL; + str = str + ret + EOL; } + return str; } void main(String[] args) { - URL url = new URL("http://dimolto.cr.ie.u-ryukyu.ac.jp/~aotokage/post.php"); + URL url = new URL("http://dimolto.cr.ie.u-ryukyu.ac.jp/~aotokage/cache.php"); HttpRequest r = new HttpRequest(url); r.openConnection(); r.setMethod("POST"); @@ -22,13 +21,13 @@ r.setRequestProperty("Cache-Control","no-cache"); r.setRequestProperty("Accept-Language","en"); r.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); - r.setBody("sub=AAAAAAAA&txt=BBB"); + r.setBody("cacheA=AAAAAAAA&cacheB=BBB"); r.writeRequest(); - r.printRequest(); - +// r.printRequest(); InputStream in = r.getInputStream(); - printResponse(in); + String ret = getResponse(in); + OUT <<< ret.split("\n\n")[1] <<< EOL; r.close(); } \ No newline at end of file diff -r 0335cdd081d0 -r bc647a5f0421 http/url.k --- a/http/url.k Mon May 28 23:56:15 2012 +0900 +++ b/http/url.k Tue May 29 00:22:51 2012 +0900 @@ -26,7 +26,6 @@ this.uri = "/"; this.host = str; } else { - print "ret = " + ret + this.host; this.host = str.split("/")[0]; this.uri = copyString(str, ret); }