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 ");
OutputStream os =urlconn.getOutputStream();
InputStream response =urlconn.getInputStream();