Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending headers using URL class 1

Status
Not open for further replies.

developerinlondon

Programmer
Jan 11, 2003
196
GB
Does anyone know of a way I can add a header to send in the URL class?
 
URL's don't have headers. Are you talking about HTTP requests?
 
yes, I am trying to send an HTTP request and pass a header to it. So far URL class was enough to fetch remote documents.
 
Have you looked at the HttpURLConnection class?
 
thanks for that.
it looks better but i cant seem to find any setHeader or equivalent type of functions on it? do you have some examples of passing headers with HTTPURLConnection?
 
ok got it!
its
Code:
           conn.setRequestProperty("test-header","test-value");

thanks again tim. i shall purple-star thee for thoust valuable comment!
 
Well, I'm not sure if I'm misleading us both. The setRequestProperty is actually defined in the URLConnection class. HttpURLConnection subclasses URLConnection.
 
oh?

yes actually you are right! i must have overlooked that function all along! i reverted it back to the URLConnection class and its working still! Probably better off using the URLConnection version if I dont need the extra functionality.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top