Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Http 1.0

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi - I need to use the HTTP 1.0 protocol for a web server I am trying to post to. In that, I need the request headers to send explicitly
POST <URL> HTTP/1.0.

When I use HttpURLConnection, I cant seem to find a way for it to send 1.0 instead of 1.1, i.e it sends HTTP/1.1. Also, it seems to send only the resource in the <URL> paramater, i.e for http://foo.com/bar it sends /bar when I need it to send http://foo.com/bar.

This requirement is being driven by a government server, so I cannot change it. Do I need to manually code the transmission of the request headers or is there a way to make HttpURLConnection do whats needed? Or is there another object that might work in place of HttpURLConnection?

Thanks much for any help.
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The HttpClient library provides a number of options that HttpURLConnection doesn't have; maybe selecting the protocol version is one of them.

As to sending the complete URL, I don't think that's possible. Does the ptotocol specification even allow that? It would in any case be superfluous, as the connection to the server has been established at that point, so sending the server name again doesn't provide any information.
 
Brian Mozhdehi
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks much for this, much appreciated. I agree with what you are saying on the specification/entire URL. It isnt part of the specification I dont think. I may end up having to write directly to the stream. But at least I can try HttpClient and see what happens. Maybe I can "extend" to allow the variation. On a side note, this whole project is crazy - its a Canadian government thing, this is among their many requirements that make no sense
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You send the whole URL in that location when you're talking to a proxy server; is that what's going on here?
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic