[VW7.5] [Bug/Weirdness] [Browser works, HttpRequest doesn't?]

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[VW7.5] [Bug/Weirdness] [Browser works, HttpRequest doesn't?]

Stew MacLean

Hi,

 

Previously this snippet to get ones external IP address worked just fine:

 

| httpClient request response |

 

            httpClient := Net.HttpClient new.

            request := Net.HttpRequest get: 'http://whatismyip.com'.

            response := httpClient executeRequest: request.

 

            ^response code = '200'

                        ifTrue: [((response value getValue readStream upToAll: '</TITLE>')

                                                            reverse readStream upTo: Character space) reverse]

                        ifFalse: ['']

 

Now, for me, it is timing out.

 

However if I paste the url into the browser that works fine.

 

Other url’s don’t time out, such as www.google.com with this snippet.

 

I’m curious as to why this is no longer working, and just for this url.

 

Any suggestions?

 

Thanks,

 

Stewart

 

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: [VW7.5] [Bug/Weirdness] [Browser works, HttpRequest doesn't?]

Reinout Heeck
Stewart MacLean wrote:

>             request := Net.HttpRequest get: 'http://whatismyip.com'.

Does the behavior change when you add a trailing slash to the url?

Most servers will not send back a '200' response but redirect (3xx) to
the url with a slash appended (or with '/index.html' appended).

A gotcha could be that the server is malconfigured, for instance it
keeps redirecting you to your original url instead of to a new one...




R
-

Reply | Threaded
Open this post in threaded view
|

RE: [VW7.5] [Bug/Weirdness] [Browser works, HttpRequest doesn't?]

Stew MacLean
No, it doesn't. I've tried this code with other "get IP address" sites
and it works fine. And it works fine in the browser. And it use to work!

Very strange...

>-----Original Message-----
>From: Reinout Heeck [mailto:[hidden email]]
>Sent: 19 June 2007 12:10 a.m.
>To: [hidden email]
>Subject: Re: [VW7.5] [Bug/Weirdness] [Browser works, HttpRequest
doesn't?]

>
>Stewart MacLean wrote:
>
>>             request := Net.HttpRequest get: 'http://whatismyip.com'.
>
>Does the behavior change when you add a trailing slash to the url?
>
>Most servers will not send back a '200' response but redirect (3xx) to
>the url with a slash appended (or with '/index.html' appended).
>
>A gotcha could be that the server is malconfigured, for instance it
>keeps redirecting you to your original url instead of to a new one...
>
>
>
>
>R
>-



Reply | Threaded
Open this post in threaded view
|

Re: [VW7.5] [Bug/Weirdness] [Browser works, HttpRequest doesn't?]

Reinout Heeck

So I took the 'trouble' to actually run your code.

Open the debugger when your code hangs, then scroll down to
Net.Httpbuildhandler>>readStream:length:lineEndConvention:

The code expects a body of size 2113 in my case, but the server seems to
send 1 byte too few, so VW keeps waiting for that last byte until a
timeout occurs.

I don't know whether this is a bug in the server or in VW (the VW code
seems somewhat hairy to me with line-end conversion possibly interfering
with the counting of bytes).



R
-



Stewart MacLean wrote:

> No, it doesn't. I've tried this code with other "get IP address" sites
> and it works fine. And it works fine in the browser. And it use to work!
>
> Very strange...
>
>> -----Original Message-----
>> From: Reinout Heeck [mailto:[hidden email]]
>> Sent: 19 June 2007 12:10 a.m.
>> To: [hidden email]
>> Subject: Re: [VW7.5] [Bug/Weirdness] [Browser works, HttpRequest
> doesn't?]
>> Stewart MacLean wrote:
>>
>>>             request := Net.HttpRequest get: 'http://whatismyip.com'.
>> Does the behavior change when you add a trailing slash to the url?
>>
>> Most servers will not send back a '200' response but redirect (3xx) to
>> the url with a slash appended (or with '/index.html' appended).
>>
>> A gotcha could be that the server is malconfigured, for instance it
>> keeps redirecting you to your original url instead of to a new one...
>>
>>
>>
>>
>> R
>> -
>
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: [VW7.5] [Bug/Weirdness] [Browser works, HttpRequest doesn't?]

Reinout Heeck
Reinout Heeck wrote:
> I don't know whether this is a bug in the server or in VW


I blame the server for being messy (but not in violation of standards!)
and VW for not handling that properly: looking at the collection
underlying the socket's incoming stream I see this separation between
headers and body:

239:  $t "16r0074"
240:  $e "16r0065"
241:  Core.Character cr
242:  Core.Character lf
243:  Core.Character cr
244:  Core.Character lf
245:  Core.Character lf
246:  $< "16r003C"
247:  $! "16r0021"


there is one dangling lf there, also further into the body:

2216:  $/ "16r002F"
2217:  $a "16r0061"
2218:  $> "16r003E"
2219:  Core.Character lf
2220:  Core.Character space
2221:  Core.Character space
2222:  Core.Character space
2223:  Core.Character space
2224:  Core.Character space
2225:  Core.Character space
2226:  Core.Character space
2227:  Core.Character space
2228:  $< "16r003C"
2229:  $/ "16r002F"
2230:  $d "16r0064"
2231:  $i "16r0069"
2232:  $v "16r0076"
2233:  $> "16r003E"
2234:  Core.Character cr
2235:  Core.Character space


cr and lf are in mixed use here.



Content-length header is set to 2113, the first byte is at position 245
(the lf above),the last at 2357 which seems consistent to me, so I guess
VW is tripped up by mixed line end conventions (crlf in the headers,
mixed cr or lf in the body) and screws up the counting of bytes...


HTH,

Reinout
-------

Reply | Threaded
Open this post in threaded view
|

RE: [VW7.5] [Bug/Weirdness] [Browser works, HttpRequest doesn't?]

Kogan, Tamara
In reply to this post by Stew MacLean
We have already done some cleaning for 751 Net clients and it looks like
the reported problem is gone.

I am wondering if you can try the new package from the public repository

NetClientsSupport 751 40
You will need also some extensions for the EncodedStream from the
attached file.

Tamara Kogan
Smalltalk development,
Cincom Systems

> -----Original Message-----
> From: Stewart MacLean [mailto:[hidden email]]
> Sent: Monday, June 18, 2007 7:49 AM
> To: [hidden email]
> Subject: [VW7.5] [Bug/Weirdness] [Browser works, HttpRequest doesn't?]
>
> Hi,
>
> Previously this snippet to get ones external IP address worked just
fine:

>
> | httpClient request response |
>
>             httpClient := Net.HttpClient new.
>             request := Net.HttpRequest get: 'http://whatismyip.com'.
>             response := httpClient executeRequest: request.
>
>             ^response code = '200'
>                         ifTrue: [((response value getValue readStream
> upToAll: '</TITLE>')
>                                                             reverse
> readStream upTo: Character space) reverse]
>                         ifFalse: ['']
>
> Now, for me, it is timing out.
>
> However if I paste the url into the browser that works fine.
>
> Other url's don't time out, such as www.google.com
> <http://www.google.com/>  with this snippet.
>
> I'm curious as to why this is no longer working, and just for this
url.

>
> Any suggestions?
>
> Thanks,
>
> Stewart
>
>
>
>

encodedStreamExt.zip (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: [VW7.5] [Bug/Weirdness] [Browser works, HttpRequest doesn't?]

Daniel Klein-4
In reply to this post by Stew MacLean
I got it to work by changing the url to 'http://www.whatsmyip.com'.
 
Daniel Klein


From: Stewart MacLean [mailto:[hidden email]]
Sent: Monday, June 18, 2007 7:49 AM
To: [hidden email]
Subject: [VW7.5] [Bug/Weirdness] [Browser works, HttpRequest doesn't?]

Hi,

 

Previously this snippet to get ones external IP address worked just fine:

 

| httpClient request response |

 

            httpClient := Net.HttpClient new.

            request := Net.HttpRequest get: 'http://whatismyip.com'.

            response := httpClient executeRequest: request.

 

            ^response code = '200'

                        ifTrue: [((response value getValue readStream upToAll: '</TITLE>')

                                                            reverse readStream upTo: Character space) reverse]

                        ifFalse: ['']

 

Now, for me, it is timing out.

 

However if I paste the url into the browser that works fine.

 

Other url’s don’t time out, such as www.google.com with this snippet.

 

I’m curious as to why this is no longer working, and just for this url.

 

Any suggestions?

 

Thanks,

 

Stewart

 

 

 

 

Reply | Threaded
Open this post in threaded view
|

RE: [VW7.5] [Bug/Weirdness] [Browser works, HttpRequest doesn't?]

Stew MacLean

I tried that as well, but didn’t work. After updating with Tamara’s suggestions it worked.

 

Cheers,

 

Stewart

 

-----Original Message-----
From: Daniel Klein [mailto:[hidden email]]
Sent:
19 June 2007 12:09 p.m.
To: [hidden email]
Subject: RE: [VW7.5] [Bug/Weirdness] [Browser works, HttpRequest doesn't?]

 

I got it to work by changing the url to 'http://www.whatsmyip.com'.

 

Daniel Klein

 


From: Stewart MacLean [mailto:[hidden email]]
Sent:
Monday, June 18, 2007 7:49 AM
To: [hidden email]
Subject: [VW7.5] [Bug/Weirdness] [Browser works, HttpRequest doesn't?]

Hi,

 

Previously this snippet to get ones external IP address worked just fine:

 

| httpClient request response |

 

          httpClient := Net.HttpClient new.

          request := Net.HttpRequest get: 'http://whatismyip.com'.

          response := httpClient executeRequest: request.

 

          ^response code = '200'

                      ifTrue: [((response value getValue readStream upToAll: '</TITLE>')

                                                          reverse readStream upTo: Character space) reverse]

                      ifFalse: ['']

 

Now, for me, it is timing out.

 

However if I paste the url into the browser that works fine.

 

Other url’s don’t time out, such as www.google.com with this snippet.

 

I’m curious as to why this is no longer working, and just for this url.

 

Any suggestions?

 

Thanks,

 

Stewart