473,581 Members | 2,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to set an http request header used in HttpURLConnecti on ?

Is it possible for a Java network application, using HttpURLConnecti on, to
set or influence the setting of, http headers like Connection. One example
might be setting Connection: Close to indicate that this is the last
expected transaction for a while and the persistent connection can be closed
with the response.
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 17 '05 #1
5 44346

<ma***@sbcgloba l.net> wrote in message news:40******** **@127.0.0.1...
Is it possible for a Java network application, using HttpURLConnecti on, to
set or influence the setting of, http headers like Connection. One example
might be setting Connection: Close to indicate that this is the last
expected transaction for a while and the persistent connection can be closed with the response.
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption

=---

Look at setRequestPrope rty/addRequestPrope rty.

Silvio Bierman
Jul 17 '05 #2
Maby you want to look at this:
http://jakarta.apache.org/commons/httpclient/

On Mon, 17 May 2004 13:05:21 GMT, <ma***@sbcgloba l.net> wrote:
Is it possible for a Java network application, using HttpURLConnecti on,
to
set or influence the setting of, http headers like Connection. One
example
might be setting Connection: Close to indicate that this is the last
expected transaction for a while and the persistent connection can be
closed
with the response.
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet
News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000
Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via
Encryption =---


--
// Daniel Jensen Aka. Daniboy
Da******@456bel ieveit131hotmai l.com
Jul 17 '05 #3
setRequestPrope rty will throw an Illegal State Exception - Already
connected. This is a persistent connection.
Jul 17 '05 #4
You trying to use that method af connection have been established?

On Wed, 19 May 2004 01:58:14 GMT, <ma***@sbcgloba l.net> wrote:
setRequestPrope rty will throw an Illegal State Exception - Already
connected. This is a persistent connection.


--
// Daniel Jensen Aka. Daniboy
Da******@456bel ieveit131hotmai l.com
Jul 17 '05 #5
//proving http persistent connections - two test sequences.
//#1 Two requests with a permission to close on the second.
//#2 Two requests with no permission to close on the second - server
keep-alive (misnomer) timeout.

import java.net.*;
import java.io.*;
class Httppersist
{

public static void main(String[] args) throws Exception
{
URL url = null;
HttpURLConnecti on conn = null;
BufferedReader respContent = null;
PrintWriter display;
String respLine;
//request 1
url = new URL("http://CHCCW1.win.well sfargo.com/gmTest/1a.txt");
conn = (HttpURLConnect ion) url.openConnect ion();
System.out.prin tln("Test 1, req 1: response code = " +
conn.getRespons eCode());
respContent = new BufferedReader( new
InputStreamRead er(conn.getInpu tStream()));
display = new PrintWriter(Sys tem.out);
while( (respLine = respContent.rea dLine()) != null)
{
display.println (respLine);
}
display.flush() ;
respContent.clo se();
conn.disconnect ();

//request 2 with a Connection: close
url = new URL("http://CHCCW1.win.well sfargo.com/gmTest/1b.txt");
conn.setRequest Property("Conne ction", "Close"); // *** thows exception
***
conn = (HttpURLConnect ion) url.openConnect ion();
System.out.prin tln("Test 1, req 2: response code = " +
conn.getRespons eCode());
respContent = new BufferedReader( new
InputStreamRead er(conn.getInpu tStream()));
display = new PrintWriter(Sys tem.out);
while( (respLine = respContent.rea dLine()) != null)
{
display.println (respLine);
}

display.flush() ;
respContent.clo se();
conn.disconnect ();
}

}
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1230
by: boohoo | last post by:
Let's say I want to use the msxml object to call a web page from within my script, and on the querystring or "in the header" of that request I want to include a dictionary object, such that the called .asp page can then request the object to it's script and use the dictionary object. Has anyone seen anything that describes marshaling an...
2
7206
by: Mak | last post by:
Hi Everybody, I try set the Expect: 100-continue in my request to server. The way I do it is by setting : <META http-equiv="Expect" content="100-continue"> in my html page. But, it does not do the trick. Can anyone let me know how to do that ? Thanks in advances.
7
7718
by: mike | last post by:
regards: Does each HTTP Request have "Host:" header? Any positive suggestion is welcome. thank you May goodness be with you all
4
1767
by: mike | last post by:
regards: Is it possible to get the next hyperlink location in "EACH HTTP REQUEST HEADER?" Or, --------------------------------------------------------------------------- Does the following programming architecture make sense? http://www.wretch.cc/album/show.php?i=otp&b=1&f=1114017894&p=4...
1
11040
by: mrbog | last post by:
Hello, I'm making HTTP requests with System.Net.HTTPWebRequest and I want to capture the entire header of the request as a string. I'm able to do this with responses but now the requests. Am I missing it in the API somewhere or is there another way? thank you
6
6087
by: Dave Slinn | last post by:
I have a VB app hosting the Webbrowser control. I would like to add "something" to the requests that app is submitted to our web application to indicate that its from this webbrowser and not a separate instance of IE. Is this possible, keeping in mind that I cannot add anything to the registry, since a user may still use IE to visit the web...
1
3127
by: Shashank | last post by:
Hi all, I am a new member of this community. I am making a http request to a html file placed on a Apache server. On this page there is an embeded perl statement which requires reading environment variables from the server. When I am typing the url of the html page in my browser, I am able to read the Environment variables from the server...
5
14103
by: dabei | last post by:
Hi, I am trying to use AS3 to make a URL request with authorization header. Using the code below: var request:URLRequest = new URLRequest ( 'http://myserviceURL' ); var requestHeader:URLRequestHeader = new URLRequestHeader("Authorization", "AuthSub token=CI3xlrq1DxCjtruCAw"); request.requestHeaders.push(requestHeader); ... But I get the...
1
2256
by: campos | last post by:
Hi all, I am trying to use javascript to send an HTTP/post request to a server multiple times continously. But the time used on the 1st and 2nd files are longer than others. My idea is that because of the 3-way hand shake, time to be used on transferring the first file shoule be 1 RTT longer than that of others. But the results are...
0
7876
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7804
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8180
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6563
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1409
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.