URLConnection will not write "Connection" property in header.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Andrew_Cartine
Posted On:   Friday, June 29, 2001 06:31 AM

I've been using URLConnection for a "streaming" client, basically to get around proxy issues. I made some changes here and there and all of a sudden, the URLConnection no longer writes out "Connection: Keep-Alive" - like it did two weeks ago. Here is the code: URL url = new URL( adddress ); conn = url.openConnection(); conn.setRequestProperty( "Connection", "Keep-Alive" ); conn.setRequestProperty( "mud-sucker", "steve" ); conn.setDoOutput( true ); conn.setDoInput( true ); out = conn.getOutputStream(); I've tried all kinds of stuff, lower-case, upper-case, "close"...it refus   More>>

I've been using URLConnection for a "streaming" client, basically to get around proxy issues. I made some changes here and there and all of a sudden, the URLConnection no longer writes out "Connection: Keep-Alive" - like it did two weeks ago.



Here is the code:


			
URL url = new URL( adddress );
conn = url.openConnection();
conn.setRequestProperty( "Connection", "Keep-Alive" );
conn.setRequestProperty( "mud-sucker", "steve" );
conn.setDoOutput( true );
conn.setDoInput( true );
out = conn.getOutputStream();







I've tried all kinds of stuff, lower-case, upper-case, "close"...it refuses to print the "Connection:" property. Here is an example printout of a trapped request header:


			
POST / HTTP/1.1
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Java1.3.0_01
Host: 10.0.0.4
Content-length: 25
mud-sucker: steve
Content-Type: application/x-www-form-urlencoded
Content-Length: 25



You can see, it writes the "mud-sucker" property but not "Connection." What's going on?

   <<Less

Re: URLConnection will not write "Connection" property in header.

Posted By:   Tim_Rohaly  
Posted On:   Friday, June 29, 2001 03:29 PM

Strange indeed, but I can't reproduce this with Java 1.3.1.
Your code works properly for me.
Your other post (http://www.jguru.com/forums/view.jsp?EID=447767
indicates that you are working
with two different versions of Java, 1.3.0_01 and
1.3.0_02. Sun's bug database indicates some
problems were reported (and fixed) related to
setting the keep-alive header in older versions
of Java 1.3 - search the bug database at http://developer.java.sun.com/developer/bugParade/index.jshtml
to see if one of these matches your problem.


Certainly, this has been fixed in 1.3.1 since it
works for me. I suspect it was also fixed in
1.3.0_02 (since the headers changed between
_01 and _02), so I suggest you try the same thing
with 1.3.0_02 and see if it works for you.

About | Sitemap | Contact