I need to set source IP address (for something like IP Spoofing) before sending out an http request. Class used for setting up http connection is HTTPURLConnection
. I found below link on stackoverflow which is really useful.
Registering and using a custom java.net.URL protocol
As in the post, I have already created 3 classes extending URLConnection
, URLStreamHandler
and implementing URLStreamHandlerFactory
. This looks to be working fine; however I am getting exception which I think is because I have not implemented getInputStream
for URLConnection
as was mentioned in above post.
I have couple of questions
1> I am extending custom URLConnection
class from HTTPURLConnection
, so what's the need of implementing getInputStream
as anyway it's a virtual method
2> If I have to do it, can someone provide sample implementation of this method?