- From: Jacob W. Anderson <jwa@zen.praja.com>
- Date: Thu, 12 Feb 1998 18:23:43 -0800
- To: <chris@surewould.com>, <www-talk@w3.org>
> URL url = new URL(urlName); > Socket webSock = new Socket(url.getHost(), 80); If you're using a proxy, this strategy will fail. You can get the output stream for the URL by calling URL.openConnection() and casting the URLConnection class to an HttpURLConnection. From HttpURLConnection you can get the output stream, which you can convert to a DataOutputStream and voila'! > out.println("POST " + url.getFile() + " HTTP/1.0"); > out.println("Connection: Keep-Alive"); > ... You need "\r\n" (CRLF) as the terminator for each header line. When you're done with the headers, just before the content, you need to send a blank line CRLF: POST this/url/thingie HTTP/1.1\r\n Connection: Keep-Alive\r\n Content-Type: application/octet-stream\r\n Content-Length: 500\r\n \r\n 500 bytes of data That's all it takes. Since you are specifying Keep-Alive, you need to request HTTP/1.1 as your protocol, otherwise you can't do keep-alive and the server will cut off the connection when it generates a response. --Jacob W. Anderson (jwa@praja.com)
Received on Thursday, 12 February 1998 21:24:41 UTC