We help IT Professionals succeed at work.

URL fails with IdHttp.get, works fine in browser

Medium Priority
2,050 Views
Last Modified: 2013-11-19
The following URL works fine when pasted into a Browser:
http://tigerweb.geo.census.gov/ArcGIS/services/tigerWMS/MapServer/WMSServer?&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=Linear%20Hydrography&STYLES=&SRS=EPSG:4326&BBox=-91.64,43.30,-91.36,43.53&WIDTH=542&HEIGHT=671&FORMAT=image/jpeg

But you get "invalid request" from the server when you use this URL in idhttp.get(URL,stream);

Any ideas - I think it may be something in the http header that indy is sending?
Comment
Watch Question

Marco GasiFreelancer
CERTIFIED EXPERT
Top Expert 2010

Commented:
Try to set Request->UserAgent to Mozilla/3.0 for your idHttp component

Cheers

Author

Commented:
Thanks, that's apparently the default, and that's what I've been using - sadly, it doesn't work. Is there another option for the UserAgent?

Added background:
I've left everything in the IdHttp at default settings.
the Actual response I get is "HTTP/1.1 400 Bad Request"
Marco GasiFreelancer
CERTIFIED EXPERT
Top Expert 2010

Commented:
From Delphi 7 up to Delphi 2010 the default value for that property is "Mozilla/3.0 (compatible; Indy Library)" and this raises a bad request error: setting the value to simply "Mozilla/3.0" solved my problems. Be sure nothing is after "Mozilla/3.0".

If this doesn't helòp you, unfortunately I can't figure out any other solution...

Cheers

Author

Commented:
Thanks marqusG, but that didn't do it.
Marco GasiFreelancer
CERTIFIED EXPERT
Top Expert 2010

Commented:
I'm very sorry, soballe. Good luck.
Commented:
I have pretty much given up on INDY for this specific problem and have gone with an WinInet approach instead using the InternetOpenURL and InternetReadFile functions.  The WinINET approach works fine, but anyone who knows how to fix the INDY problem, I'd really like to hear it for future reference.

Thanks,

Author

Commented:
The WinINET approach with Delphi is well documented and there are plenty of examples posted on line that actually work - no more time right now to mess around with Indy's HTTP component.