Mercurial > hg > Members > nobuyasu > konoha
view http/httpRequestTest.k @ 14:bc647a5f0421 draft
modify HttpRequest.k
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 29 May 2012 00:22:51 +0900 |
parents | 0335cdd081d0 |
children |
line wrap: on
line source
include "HttpRequest.k" String getResponse(InputStream in) { String str = ""; while ( !in.isClosed() ) { String ret = in.readLine(); str = str + ret + EOL; } return str; } void main(String[] args) { 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"); r.setRequestProperty("Connection","close"); r.setRequestProperty("Accept-Charset","UTF-8"); r.setRequestProperty("Cache-Control","no-cache"); r.setRequestProperty("Accept-Language","en"); r.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); r.setBody("cacheA=AAAAAAAA&cacheB=BBB"); r.writeRequest(); // r.printRequest(); InputStream in = r.getInputStream(); String ret = getResponse(in); OUT <<< ret.split("\n\n")[1] <<< EOL; r.close(); }