I have coded my own HTTP Server.
I want to make access the HTTP Server using HttpURLConnection class faster. I think I can provide a customized URLStreamHandler which created a customized HttpURLConnection object wrapping an object of the jdk default implementation. This HttpURLConnection checks whether the target server is within a same jvm (My HTTP Server provide a inquery API). If no, it will create a Socket object, and if yes, it will create a inmemory pipe instead of a socket for use. After that, all methods invocation are delegate to the wrapped default implementation. (That is to say, I still want to reuse default HttpURLConnection implementation instead of creating everything)
Can I make all of this totally transparent to typical client code written as below ?
URL url =new URL("http://someserver/file ");
URLConnection urlconn =url.openConnection();
urlconn.setRequestHeader("METHOD ","POST ");
urlconn.setContentType("
application/x-www-form-urlencoded ");
urlconn.connect();
OutputStream os =urlconn.getOutputStream();
InputStream response =urlconn.getInputStream();
...
-
Create a HttpURLConnection wrapping default impl (1 messages)
- Posted by: Xun Zhang
- Posted on: March 13 2006 18:26 EST
Threaded Messages (1)
- Create a HttpURLConnection wrapping default impl by Jeryl Cook on March 22 2006 21:50 EST
-
Create a HttpURLConnection wrapping default impl[ Go to top ]
- Posted by: Jeryl Cook
- Posted on: March 22 2006 21:50 EST
- in response to Xun Zhang
Not sure why u would want to code your own HTTP Server. :)...Apache is free.
If this is for production use..you shoudl use the HTTPClient pacakage its free also..
http://jakarta.apache.org/commons/httpclient/