Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to customize my HttpURLConnection to modify http response header?

user12956197Apr 12 2013 — edited Apr 16 2013
hi
I have a problem with javafx brower(2523487
I want to implement my HttpURLConnection which extends sun.net.www.protocol.http.HttpURLConnection.
@Override
public synchronized InputStream getInputStream() throws IOException {
InputStream is=super.getInputStream();

if(this.url.toExternalForm().startsWith("http://map.baidu.com/su")){
super.getHeaderField("Content-Type");
//I want to modify response header here.
}
return is;
}

but the response headers are stored in " private MessageHeader responses;". I can't modify it.

I want to copy sun.net.www.protocol.http.HttpURLConnection out and modify it myself. but I can't get source codes of it in JDK/src.zip.
I searched and found http://grepcode.com/snapshot/repository.grepcode.com/java/root/jdk/openjdk/7-b147/
but it depends so many things of sun.net package.

any good method for me ? thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 14 2013
Added on Apr 12 2013
9 comments
6,793 views