setting http/1.0 protcol in the HttpURLConnection

I want to set http/1.0 protocol in the HttpURLConnection that i create.

Is there any method in HttpURLConnection, that an be used to do so.

Thanking in advance

cheers
Suddu,
sudarshan_sharma22Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ramazanyichCommented:
no. It is hardcoded into implementation sun.net.www.protocol.http.HttpURLConnection
0
zzynxSoftware engineerCommented:
See http://micro5.mscc.huji.ac.il/~aries/net2.html
Search for: "Start sending our reply, using the HTTP 1.0 protocol"
0
ajvedCommented:
Do not need to connect a packet.... need to use HttpURLConnection or objects as such :(
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

sudhakar_koundinyaCommented:
ignore previous statement
0
ramazanyichCommented:
http://www.innovation.ch/java/HTTPClient/getting_started.html

An HttpURLConnection class and the necessary URLStreamHandlers are provided so that you may easily replace the JDK's HttpClient with the HTTPClient. All you need to do is define the java system property java.protocol.handler.pkgs as HTTPClient. For example, on the command line this would look like

    java -Djava.protocol.handler.pkgs=HTTPClient MyApp

Invoking URL.openConnection() will then return an instance of HTTPClient.HttpURLConnection.

Note that there are a couple small differences compared to Sun's HttpClient when POSTing - please see the class documentation for more information.
0
ramazanyichCommented:
addition to my previous message: you can force HTTP/1.0 request by setting -DHTTPClient.forceHTTP_1.0=true proeprty to you JVM. So your call to your application will be:
java -classpath HTTPClient.jar  -Djava.protocol.handler.pkgs=HTTPClient  -DHTTPClient.forceHTTP_1.0=true MyAPP
0
sudarshan_sharma22Author Commented:
Venabili, Sorry for the caused confusion.

We Aren't the same person,

Bu we know each other and thats something which he was also looking for and i adviced him to observe this thread which would be helpful for him too.

The comment added by him is something is what he is looking for.

Regards,
Suddu.






0
zzynxSoftware engineerCommented:
>> i adviced him to observe this thread
To avoid any confusion in the future, when he adds comments like this, let him first mention in the comment
- that he is not the author
- but that he is a colleague interested in the same solution
0
ajvedCommented:
zzynx,

Thanks for the suggestion, henceforth i will ensure that i add these as the comments while trailing the thread.

regards
0
VenabiliCommented:
I would advice you NOT to use this thread for your own question but to ask a separate one (or if it is the same trouble to leave the Asker to respond here). Otherwise it is a missuse of the points system(using  questions from other people )

Venabili
0
sudarshan_sharma22Author Commented:
I followed the steps given by ramazanyich. I was  hitting to a jsp in Resin. BY using getProtocol i got http1.1.

Am yet to find a soln. Seems like java has hard coded to use http1.0 protocol.

Regards,
Sudarshan
0
ramazanyichCommented:
to check that browser sent really HTTP/1.0 request you choose wrong method. Better use some network  monitoring tools. I used Ethereal (www.ethereal.org) and used my solution.
I wrote simple program:
public class HttpTest {
   
    public static void main(String[] args) {
        try{
        URL url = new URL(args[0]);
        HttpURLConnection conn = (HttpURLConnection)url.openConnection();
       
        System.out.println(conn.getContent());
        System.out.println(conn.getResponseCode());
        }catch(Exception e){
            e.printStackTrace();
        }
       
    }

}

I started Ethereal and execuited my program with HTTPClient:
java -classpath c:\distr\HTTPClient.zip;bin  -Djava.protocol.handler.pkgs=HTTPClient  -DHTTPClient.forceHTTP_1.0=true  HttpTest http://www.microsoft.com

And I got follwoing on ethereal:

GET / HTTP/1.0
Host: www.microsoft.com
Connection: Keep-Alive, TE
TE: trailers, deflate, gzip, compress
User-Agent: RPT-HTTPClient/0.3-3
Accept-Encoding: deflate, gzip, x-gzip, compress, x-compress

HTTP/1.1 200 OK
Cache-Control: public
Content-Length: 13300
Content-Type: text/html
....
As you can see browser sent HTTP/1.0 request.,
but server replied with HTTP/1.1

And if I don't use HTTPClient then I got follwoing in Ethereal:
GET / HTTP/1.1
User-Agent: Java/1.4.2_06
Host: www.microsoft.com
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive

HTTP/1.1 200 OK
Cache-Control: public
Content-Length: 13300
Content-Type: text/html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.