Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
6
Erster Beitrag:
vor 8 Jahren, 2 Monaten
Letzter Beitrag:
vor 8 Jahren, 2 Monaten
Beteiligte Autoren:
Piet van Zanten, Pascal Scheffers

HTTPRequest() fails when the same URL works in browser

Startbeitrag von Pascal Scheffers am 27.04.2010 09:02

We've been struggling with some URLs which just do not work in Windev 14 and now 15 which work perfectly for all webbrowsers. I've contacted the Patrick at the helpdesk, but he couldn't immediately reproduce the issue - which is *also* what we see with our customers. The URL which doesn't work for us, does sometimes work for some customers... very frustrating. So I'm looking for some more data... I'd like you to run the following snippet of code and post the result here:


rpt is string
HTTPTimeOut(10) // I don't want you waiting 30 seconds
FOR EACH STRING url OF "http://unitas.nl/rss.xml http://douane.nl/rss/douane-serviceberichten.xml"; SEPARATED BY " "
IF HTTPRequest(url) THEN
rpt+=StringBuild("Request to %1 worked. %2 bytes received.", url, Length(HTTPGetResult()))+RC
FOR EACH STRING s OF HTTPGetResult(httpHeader) SEPARATED BY RC
IF s[="X" OR s[="Proxy" THEN rpt+=s+RC
END
ELSE
rpt+=StringBuild("FAILED: Request to %1.", url)+RC
END
END
ToClipboard(rpt)
Info(rpt, "The above text is now on your clipboard, please paste your result on the forum.")



The first URL, which is our own server, always works. The second one usually doesn't work. Which is why I set the timeout to a short time. When it does work for our customers, they generally have a proxy server installed. Which is what this piece of code is trying to detect with the inner for each loop.

The second URL is just an example, I'm seeing this behaviour with more servers. The douane.nl one is an IBM webserver, there must be more of those out there.


Antworten:

Hi Pascal,

I found that for some reason, if you use httprequest(sUrl,cr) then it works.

Regards,
Piet

von Piet van Zanten - am 27.04.2010 11:50
Yes, it appears to work, but only on the surface. I tried it and the answer you get is a 400/Bad Request. By replacing the user-agent with a CR/LF you break the HTTP Request headers.

See http://twitpic.com/1iukxf for the full exchange with your code.

But your response indicates that without modification, the second URL doesn't work, right? This is important to know, because Patrick PHILIPOT couldn't reproduce it. Can you tell me what happened?

Regards,

- Pascal.

von Pascal Scheffers - am 27.04.2010 12:09
Hi Patrick,

You are right, it only avoids the timeout error. I didn't look at the result.

If I use your code I get the timeout error.
Request to http://unitas.nl/rss.xml worked. 613 bytes received.
FAILED: Request to http://douane.nl/rss/douane-serviceberichten.xml.

Try using wireshark to trace the traffic and compare the differences between the browser and the httprequest.

Regards,
Piet


von Piet van Zanten - am 27.04.2010 12:20
(It's Pascal :-) )

SockSpy is perfect for debugging HTTP exchanges. Mostly transparent, if that doesn't work wireshark is my next choice, but I find it more of a hassle to work with.

My guess as to why this is happening... The douane.nl server (which fails) does a connection: keep-alive when Windev requests a Connection: close. So it seems the HttpRequest doesn't use the Content-Length from the header, but waits for the connection to close (which would be an incorrect HTTP/1.1 implementation). It is silly for the server to ignore the connection: close from the client, but that is IBM for you...

- Pascal.

von Pascal Scheffers - am 27.04.2010 12:42
Sorry Pascal, for mistaking your name. :eek:
I'll look into Sockspy, thanks for the tip.
I was using Wireshark extensively to try and get httprequest working with cookies to keep a session alive. In which the carriage return played an important role. See previous post http://forum.mysnip.de/read.php?27131,19082,19614#msg-19614.

Regards,
Piet

von Piet van Zanten - am 27.04.2010 16:15
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.