Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Http 1.0/1.1

  • 19-09-2002 10:33am
    #1
    Closed Accounts Posts: 536 ✭✭✭


    ok I've a little problem here, my java app has been written using HTTP 1.1.
    To be honest I did'nt even know there were different versions, I just open the url connection and work away.

    Anyway the server I'm meant to be connecting to uses HTTP 1.0
    and it's causing problems for us.
    (someone else is developing the server)

    What's the story with HTTP versions?

    Can I easily change the version?


    I'm using jbuilder to develop my application and JDK 1.4 also.

    Any help would be appreciated!


Comments

  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Why don't you just open a socket and send HTTP 1.0 headers?

    Still, it seems odd as most current browsers will send HTTP 1.1 request headers when connecting to a server (even if the server sends back a HTTP 1.0 response), and anyhow, there's not a hell of a lot of difference between the two request versions.

    What exactly are you trying to do?


  • Closed Accounts Posts: 536 ✭✭✭flyz


    Originally posted by The Corinthian
    Why don't you just open a socket and send HTTP 1.0 headers?
    Excuse my ignorance but how do I do that? is it to do with setting the properties?

    the way I open my connection is as follows:

    URL myURL = new URL("http", ip, port, "/servlet_string");

    URLConnection con = myURL.openConnection();
    con.setRequestProperty("Content-Type","text/xml");
    con.setDoOutput(true);
    con.setDoInput(true);
    PrintWriter out=new PrintWriter(con.getOutputStream());
    out.write(xml_stuff);

    I don't use any browsers as such, what I'm doing is connecting my java application to a server to retrieve information, it's all low level. there is no interface to the http stuff.

    I have the application working fine connecting to a servlet, but the next stage is to have the server on the hardware and the application connect to that instead. That server is being written in C I think.

    I hope I haven't confused you even more :p


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Originally posted by flyz
    Excuse my ignorance but how do I do that? is it to do with setting the properties?
    No. I was simply stating that browsers, such as IE5, send HTTP 1.1 requests, if if you can point to the server in question with IE5, then I doubt it's the HTTP version that's the problem.

    Another thing I'll note is that Content-Type is a response and not a request header and the server may not like it (why you need it in a request, is another question).

    What you might try is a more low-level approach than what you're doing; to open a socket to the server ip/port and pump the raw HTTP headers yourselfsuch as:
    GET /foo.html HTTP/1.0\r\n
    Other-Headers: foobar\r\n
    \r\n
    
    That way you can bypass the default HTTP version.

    I trust that's not too confusing :p


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    [ I wrote this earlier, before ye started getting into the nitty-gritty. It doesn't really apply to the thread anymore, but it might be handy to someone in future. As Corinthian suggests though, you'll need to manually open a socket to the server, and send full HTTP headers to do what you want. openConnection() looks like it does all that work for you, much like the file() and fopen() function in PHP. Alternatively, the function may have a flag to toggle the HTTP version. ]

    What's the story with HTTP versions?

    The basic difference, and primary reason HTTP/1.1 was created, is that HTTP/1.0 didn't have a 'Host:' header and so wasn't capable of supporting name-based hosting. A consequence of this is that, since every website had to have a unique IP address, the growing number of websites on the net was eating into the IP address pool. The HTTP/1.1 spec added the Host: header, the upshot of which is that if you send a HTTP/1.1 request to a webserver that supports HTTP/1.1, the webserver can read the Host: header and deliver an appropriate site programmatically. However, if you send a HTTP/1.0 request, it doesn't include the Host: header and the server doesn't know which particular site to deliver; so it delivers the default site for that IP address.

    There were of course many other changes, including improved caching support, but I don't really know much about the rest. I would suggest you compare and contrast the RFCs for each.

    adam


Advertisement