06/10/11 19:45:11
だれか教えてほしい javadocのHttpConnectionに下記のようなソースがあるけど
HttpConnection c = null;
InputStream is = null;
OutputStream os = null;
try {
c = (HttpConnection)Connector.open(url);
// Set the request method and headers
c.setRequestMethod(HttpConnection.POST)
// Getting the output stream may flush the headers
os = c.openOutputStream();
os.write("LIST games\n".getBytes());
os.flush(); // Optional, getResponseCode will flush
os.flush()てどういう動きするもんですか?
バッファリングしているものを書きだすという意味であってます?
os.flush()ではうまくデータを送れずos.close()に変更したら
ちゃんと動きました。
flushでデータ(例えば a=b)を送ろうとすると受け取った側では
3改行
改行
a=b
というデータがきます。
なんとなくこのデータの前に
Content-Length:とかついてくるような気がしてなりません。