| Author | Topic: LoadFromURL hangs when called twice upon a site that requires authentication |
---|
| Jose Adriano Baltieri | LoadFromURL hangs when called twice upon a site that requires authentication
on Wed, 02 Feb 2005 17:19:09 -0200I'm building a program that every 5 minutes query a NO-BREAK battery status,
to see time left and take some actions.
NO-BREAK offers information via HTTP, with basic authentication.
It seems to me that LoadFromURL works fine at the very first call but, later,
it gets hooked.
Have you ever experienced such a problem ?
Here's my little test program :
# INCLUDE "ASINET.CH"
PROC MAIN
LOCAL LCHTML
WHILE .T.
? "BEFORE LOADFROMURL..."
LCHTML:=LOADFROMURL("http://admin:nobreak@10.2.0.4/Status.htm",,,,,"GET")
//LCHTML:=LOADFROMURL("http://anonymous:minieme@www.alaska-software.com")
? "@ " + TIME() + " " + LEFT(LCHTML,30) + "..."
? "AFTER LOADFROMURL..."
INKEY(0)
END WHILE
RETURN
And this is how I've compiled it :
CALL SETXPP
XPP XTEST294 /A /ES /M /N /Q /V /W /ERR:20 /DLL:DYNAMIC /WN /LINK
IF ERRORLEVEL 1 GOTO EOJ
XTEST294.EXE
:EOJ
I'm almost opening a PDR.
Should you have some clue, however... |
| Jose Adriano Baltieri | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Wed, 02 Feb 2005 17:37:37 -0200About the same problem, if that is worth, LoadFromURL from Phil Ide also fails
on the same situation...
Jose Adriano Baltieri wrote:
> I'm building a program that every 5 minutes query a NO-BREAK battery
> status, to see time left and take some actions.
>
> NO-BREAK offers information via HTTP, with basic authentication.
>
> It seems to me that LoadFromURL works fine at the very first call but,
> later, it gets hooked.
>
> Have you ever experienced such a problem ?
>
> Here's my little test program :
>
> # INCLUDE "ASINET.CH"
>
> PROC MAIN
>
> LOCAL LCHTML
>
> WHILE .T.
> ? "BEFORE LOADFROMURL..."
> LCHTML:=LOADFROMURL("http://admin:nobreak@10.2.0.4/Status.htm",,,,,"GET")
> //LCHTML:=LOADFROMURL("http://anonymous:minieme@www.alaska-software.com")
> ? "@ " + TIME() + " " + LEFT(LCHTML,30) + "..."
> ? "AFTER LOADFROMURL..."
> INKEY(0)
> END WHILE
>
> RETURN
>
> And this is how I've compiled it :
>
> CALL SETXPP
> XPP XTEST294 /A /ES /M /N /Q /V /W /ERR:20 /DLL:DYNAMIC /WN /LINK
> IF ERRORLEVEL 1 GOTO EOJ
> XTEST294.EXE
> :EOJ
>
> I'm almost opening a PDR.
>
> Should you have some clue, however... |
| Thomas Braun | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Thu, 03 Feb 2005 08:11:38 +0100Jose Adriano Baltieri wrote:
> About the same problem, if that is worth, LoadFromURL from Phil Ide also fails
> on the same situation...
Did you try repeatedly with a real browser or with a program like WebBug
(http://www.cyberspyder.com/webbug.html)?
Thomas Braun |
| Jose Adriano Baltieri | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Thu, 03 Feb 2005 08:04:25 -0200Thomas Braun wrote:
> Jose Adriano Baltieri wrote:
>
>
>>About the same problem, if that is worth, LoadFromURL from Phil Ide also fails
>>on the same situation...
>
>
> Did you try repeatedly with a real browser or with a program like WebBug
> (http://www.cyberspyder.com/webbug.html)?
>
At least with a browser like Mozilla or Internet Explorer, it works fine.
Authentication is required at the very first call. Then reload is OK....
> Thomas Braun |
| Jose Adriano Baltieri | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Thu, 03 Feb 2005 09:35:19 -0200Thomas Braun wrote:
> Jose Adriano Baltieri wrote:
>
>
>>About the same problem, if that is worth, LoadFromURL from Phil Ide also fails
>>on the same situation...
>
>
> Did you try repeatedly with a real browser or with a program like WebBug
> (http://www.cyberspyder.com/webbug.html)?
>
I have tried the same process upon another Web Server and, it works.
So, there must be some particularity on this specific site that makes
LoadFromURL get hanged when called twice.
Got to see now what is it...
Thanks for your support ! |
| Thomas Braun | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Thu, 03 Feb 2005 13:21:49 +0100Jose Adriano Baltieri wrote:
> I have tried the same process upon another Web Server and, it works.
>
> So, there must be some particularity on this specific site that makes
> LoadFromURL get hanged when called twice.
>
> Got to see now what is it...
One more idea... use a tool like Ethereal to actually see what requests
LoadFromURL is submitting to the server and what replies the server sends.
Thomas |
| Jose Adriano Baltieri | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Thu, 03 Feb 2005 20:37:45 -0200Thomas Braun wrote:
> Jose Adriano Baltieri wrote:
>
>
>>I have tried the same process upon another Web Server and, it works.
>>
>>So, there must be some particularity on this specific site that makes
>>LoadFromURL get hanged when called twice.
>>
>>Got to see now what is it...
>
>
> One more idea... use a tool like Ethereal to actually see what requests
> LoadFromURL is submitting to the server and what replies the server sends.
>
> Thomas
Thank you Thomas !
I always wanted to learn to use Ethereal but I find it too complex.
I have another tool, maybe you already know, called CURL - Command Line URL.
I like it a lot cause it's command line based (I'm a console world guy) and,
it has *a*lot* of parameters.
One of them exposes the http headers.
On another posting of this thread I offered Phil Ide some captures of data.
If you dont know CURL yet, it's worth getting it.
Also because you can automate your URL captures on your batch files.
At the end of this story of mine , if I cant find a solution for LoadFromURL,
I can use RUNSHELL to run CURL and capture data because CURL works with
authentication. I just dont want to do it now cause I think it is too heavy
(and cumbersome). But it would work anyway.
Thank you again. |
| Thomas Braun | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Fri, 04 Feb 2005 08:44:53 +0100Jose Adriano Baltieri wrote:
> I always wanted to learn to use Ethereal but I find it too complex.
Ethereal can't be called *complex*, but the mere number of possible
protcols that Ethereal can display is complex
The problem in your case seems to be that there is a difference in the
communication between LoadFromURL() and the other methods.
I think only a protocol sniffer can show you what goes wrong (or Alaska has
to check this)
>
> If you dont know CURL yet, it's worth getting it.
I will take a look, thanks for that hint!
Thomas Braun |
| Phil Ide
| Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Thu, 03 Feb 2005 12:54:08 +0000Adriano,
> I'm building a program that every 5 minutes query a NO-BREAK battery status,
> to see time left and take some actions.
>
> NO-BREAK offers information via HTTP, with basic authentication.
I have a solution for you, but it requires either ASINET or Xb2.NET.
Interested? I've tested this against a protected realm on one of my local
webs, and it has no prblems at all.
Regards,
Phil Ide
***************************************
* Xbase++ FAQ, Libraries and Sources: *
* goto: http://www.idep.org.uk/xbase *
***************************************
A*C, who said A*C? |
| Phil Ide
| Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Thu, 03 Feb 2005 15:11:42 +0000Adriano,
>> I'm building a program that every 5 minutes query a NO-BREAK battery status,
>> to see time left and take some actions.
>>
>> NO-BREAK offers information via HTTP, with basic authentication.
>
> I have a solution for you, but it requires either ASINET or Xb2.NET.
> Interested? I've tested this against a protected realm on one of my local
> webs, and it has no prblems at all.
Even better, it now no longer needs ASINET or Xb2.NET. There is an
additional parameter you can pass to it which is an array containing the
authentication credentials.
LoadFromUrl(cUrl,,,,,,,,,,,{"myName","myPassword"})
I've uploaded it (now at v1.4) - so download and play and tell me whether
it works for you or not.
Regards,
Phil Ide
***************************************
* Xbase++ FAQ, Libraries and Sources: *
* goto: http://www.idep.org.uk/xbase *
***************************************
Spam Spam Spam Spam, Spammity Spammmm, Spam, Spam, Spam |
| Jose Adriano Baltieri | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Thu, 03 Feb 2005 20:34:12 -0200Phil Ide wrote:
> Adriano,
>
>
>>>I'm building a program that every 5 minutes query a NO-BREAK battery status,
>>>to see time left and take some actions.
>>>
>>>NO-BREAK offers information via HTTP, with basic authentication.
>>
>>I have a solution for you, but it requires either ASINET or Xb2.NET.
>>Interested? I've tested this against a protected realm on one of my local
>>webs, and it has no prblems at all.
>
>
> Even better, it now no longer needs ASINET or Xb2.NET. There is an
> additional parameter you can pass to it which is an array containing the
> authentication credentials.
>
> LoadFromUrl(cUrl,,,,,,,,,,,{"myName","myPassword"})
>
> I've uploaded it (now at v1.4) - so download and play and tell me whether
> it works for you or not.
First of all, thank you again.
Unfortunatelly, it didnt work. It gets hooked at the very first call.
The problem, again, is regarded to this specific site of mine (a http server
that runs inside the NO-BREAK machine).
When I run your LoadFromUrl using authentication, upon another site, it works.
But on this NO-BREAK site, there's NO-SIGNAL result.
I've managed to capture the http headers from both of them using CURL (Command
Line URL), a very useful tool on these contexts.
Here they are :
Http headers for the URL below, where the function works fine
http://tuser:tpassword@www.DES.online.unimep.br/fm/teste.htm
HTTP/1.1 200 OK
Date: Thu, 03 Feb 2005 22:33:05 GMT
Server: WebSite/3.5.17
Accept-ranges: bytes
Connection: Keep-Alive
Content-type: text/html
Last-modified: Thu, 03 Feb 2005 10:26:20 GMT
Content-length: 127
Now, the NO-BREAK headers :
HTTP/1.1 200 OK
Date: Thu, 03 Feb 2005 20:33:41 GMT
Server: NetAgent
Connection: close
Content-Length: 2569
Content-Type: text/html
Hope it can bring you some light.
>
> Regards, |
| Phil Ide
| Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Fri, 04 Feb 2005 11:25:47 +0000Adriano,
> Now, the NO-BREAK headers :
>
> HTTP/1.1 200 OK
> Date: Thu, 03 Feb 2005 20:33:41 GMT
> Server: NetAgent
> Connection: close
> Content-Length: 2569
> Content-Type: text/html
>
>
> Hope it can bring you some light.
Well, this looks ok actually. It returned a page of 2569 bytes, and the
server reported 200 OK, which means no errors (and also means no Access
Denied).
I'll take a closer look when I get your email.
Regards,
Phil Ide
***************************************
* Xbase++ FAQ, Libraries and Sources: *
* goto: http://www.idep.org.uk/xbase *
***************************************
To clone a felon, do I use the COPY CON command? |
| Jose Adriano Baltieri | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Thu, 03 Feb 2005 20:55:16 -0200Phil Ide wrote:
> Adriano,
>
>
>>>I'm building a program that every 5 minutes query a NO-BREAK battery status,
>>>to see time left and take some actions.
>>>
>>>NO-BREAK offers information via HTTP, with basic authentication.
>>
>>I have a solution for you, but it requires either ASINET or Xb2.NET.
>>Interested? I've tested this against a protected realm on one of my local
>>webs, and it has no prblems at all.
>
>
> Even better, it now no longer needs ASINET or Xb2.NET. There is an
> additional parameter you can pass to it which is an array containing the
> authentication credentials.
>
> LoadFromUrl(cUrl,,,,,,,,,,,{"myName","myPassword"})
>
> I've uploaded it (now at v1.4) - so download and play and tell me whether
> it works for you or not.
>
One more thing : if I run it with lHeadersOnly turned on, it works.
> Regards, |
| Jose Adriano Baltieri | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Thu, 03 Feb 2005 21:23:16 -0200Phil Ide wrote:
> Adriano,
>
>
>>>I'm building a program that every 5 minutes query a NO-BREAK battery status,
>>>to see time left and take some actions.
>>>
>>>NO-BREAK offers information via HTTP, with basic authentication.
>>
>>I have a solution for you, but it requires either ASINET or Xb2.NET.
>>Interested? I've tested this against a protected realm on one of my local
>>webs, and it has no prblems at all.
>
>
> Even better, it now no longer needs ASINET or Xb2.NET. There is an
> additional parameter you can pass to it which is an array containing the
> authentication credentials.
>
> LoadFromUrl(cUrl,,,,,,,,,,,{"myName","myPassword"})
>
> I've uploaded it (now at v1.4) - so download and play and tell me whether
> it works for you or not.
>
And, yet, another thing :
I have a modified version of your LoadFromURL where I added a cHTTPHeaders
parameter that is supposed to be called by reference.
I dont like your lHTTPHeaders only version because I have to hit the server twice.
I prefer to hit the server once and retrieve the header and content on a
single operation.
Should you want to have a look at this version of mine, it's attached.
Also miss in LoadFromURL a Timeout parameter...
> Regards, PILFURL.PRG |
| Phil Ide
| Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Fri, 04 Feb 2005 11:22:29 +0000Adriano,
> I have a modified version of your LoadFromURL where I added a cHTTPHeaders
> parameter that is supposed to be called by reference.
>
> I dont like your lHTTPHeaders only version because I have to hit the server twice.
No you don't.
If you ONLY want the headers, set lHttpHeaders TRUE.
If you want both the headers AND the content, pass an empty array as the
11th parameter, and set lHeadersOnly (10th parameter) to FALSE.
LoadFromUrl( cURL , ;
nPortNumber , ;
nProtocol , ;
cProxyUrl , ;
acByPass , ;
cMethod , ;
cPostString , ;
cHttpHeaders, ;
bPreCall , ;
lHeadersOnly, ;
aHeaders , ;
aAuthInfo )
aHeaders is returned looking something like this:
{
'HTTP/1.1 200 OK',
'Date: Thu, 03 Feb 2005 22:33:05 GMT',
'Server: WebSite/3.5.17',
'Accept-ranges: bytes',
'Connection: Keep-Alive',
'Content-type: text/html',
'Last-modified: Thu, 03 Feb 2005 10:26:20 GMT',
'Content-length: 127'
}
Regards,
Phil Ide
***************************************
* Xbase++ FAQ, Libraries and Sources: *
* goto: http://www.idep.org.uk/xbase *
***************************************
This operating system wasn't released... it escaped! |
| Jose Adriano Baltieri | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Fri, 04 Feb 2005 13:26:11 -0200Phil Ide wrote:
> Adriano,
>
>
>>I have a modified version of your LoadFromURL where I added a cHTTPHeaders
>>parameter that is supposed to be called by reference.
>>
>>I dont like your lHTTPHeaders only version because I have to hit the server twice.
>
>
> No you don't.
>
> If you ONLY want the headers, set lHttpHeaders TRUE.
>
> If you want both the headers AND the content, pass an empty array as the
> 11th parameter, and set lHeadersOnly (10th parameter) to FALSE.
Great. I've done like this and it worked. Also, it is nice to have the headers
returned as an array. Easy to work with. With my former approach, I had to
parse the string on my own. Now it comes ready , already.
Thanks again !
>
> LoadFromUrl( cURL , ;
> nPortNumber , ;
> nProtocol , ;
> cProxyUrl , ;
> acByPass , ;
> cMethod , ;
> cPostString , ;
> cHttpHeaders, ;
> bPreCall , ;
> lHeadersOnly, ;
> aHeaders , ;
> aAuthInfo )
>
> aHeaders is returned looking something like this:
>
> {
> 'HTTP/1.1 200 OK',
> 'Date: Thu, 03 Feb 2005 22:33:05 GMT',
> 'Server: WebSite/3.5.17',
> 'Accept-ranges: bytes',
> 'Connection: Keep-Alive',
> 'Content-type: text/html',
> 'Last-modified: Thu, 03 Feb 2005 10:26:20 GMT',
> 'Content-length: 127'
> }
>
> Regards, |
| Phil Ide
| Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Fri, 04 Feb 2005 15:55:21 +0000Adriano,
>> If you want both the headers AND the content, pass an empty array as the
>> 11th parameter, and set lHeadersOnly (10th parameter) to FALSE.
>
> Great. I've done like this and it worked. Also, it is nice to have the headers
> returned as an array. Easy to work with. With my former approach, I had to
> parse the string on my own. Now it comes ready , already.
See, it pays to pay attention to the docs . I think that feature went
in at v1.3 or possibly 1.2.
Regards,
Phil Ide
***************************************
* Xbase++ FAQ, Libraries and Sources: *
* goto: http://www.idep.org.uk/xbase *
***************************************
I Wonder What The Big Red Button Does....? |
| Jose Adriano Baltieri | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Fri, 04 Feb 2005 08:53:51 -0200Phil Ide wrote:
> Adriano,
>
>
>>>I'm building a program that every 5 minutes query a NO-BREAK battery status,
>>>to see time left and take some actions.
>>>
>>>NO-BREAK offers information via HTTP, with basic authentication.
>>
>>I have a solution for you, but it requires either ASINET or Xb2.NET.
>>Interested? I've tested this against a protected realm on one of my local
>>webs, and it has no prblems at all.
>
>
> Even better, it now no longer needs ASINET or Xb2.NET. There is an
> additional parameter you can pass to it which is an array containing the
> authentication credentials.
>
> LoadFromUrl(cUrl,,,,,,,,,,,{"myName","myPassword"})
>
> I've uploaded it (now at v1.4) - so download and play and tell me whether
> it works for you or not.
It looks like I took the day to post to you !
Well, I thought it would be nice if you could have access to this ip of our
NO-BREAK an have your tests working upon it.
Then, I changed its IP to a valid one.
I'll send you a private email with information, so that you can make your tests.
Thanks again !
>
> Regards, |
| Phil Ide
| Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Fri, 04 Feb 2005 11:33:31 +0000Adriano,
> Well, I thought it would be nice if you could have access to this ip of our
> NO-BREAK an have your tests working upon it.
>
> Then, I changed its IP to a valid one.
>
> I'll send you a private email with information, so that you can make your tests.
I've tried the IP address you sent me, and it cannot be found. I've tried
with LoadFromUrl(), Internet Explorer and PING, and I just can't see the
server at all.
Regards,
Phil Ide
***************************************
* Xbase++ FAQ, Libraries and Sources: *
* goto: http://www.idep.org.uk/xbase *
***************************************
You mean, we have ANOTHER modem to feed? |
| Jose Adriano Baltieri | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Fri, 04 Feb 2005 10:10:05 -0200Phil Ide wrote:
> Adriano,
>
>
>>Well, I thought it would be nice if you could have access to this ip of our
>>NO-BREAK an have your tests working upon it.
>>
>>Then, I changed its IP to a valid one.
>>
>>I'll send you a private email with information, so that you can make your tests.
>
>
> I've tried the IP address you sent me, and it cannot be found. I've tried
> with LoadFromUrl(), Internet Explorer and PING, and I just can't see the
> server at all.
Sorry ! It's that I had asked to the Net guy to free our firewall to you and
he hadn't done it yet.
Now it's done, I hope.
Try once more, will you ?
>
> Regards, |
| Phil Ide
| Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Fri, 04 Feb 2005 13:18:03 +0000Adriano,
>> I've tried the IP address you sent me, and it cannot be found. I've tried
>> with LoadFromUrl(), Internet Explorer and PING, and I just can't see the
>> server at all.
>
> Sorry ! It's that I had asked to the Net guy to free our firewall to you and
> he hadn't done it yet.
>
> Now it's done, I hope.
>
> Try once more, will you ?
Ok, done and found the problem and fixed it. It was a bug in a buffer test
when HTTP_QUERY_CONTENT_LENGTH failed.
I've uploaded v1.5.
Regards,
Phil Ide
***************************************
* Xbase++ FAQ, Libraries and Sources: *
* goto: http://www.idep.org.uk/xbase *
***************************************
Please excuse me while I ROFL. |
| Jose Adriano Baltieri | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Fri, 04 Feb 2005 13:13:50 -0200Phil Ide wrote:
> Adriano,
>
>
>>>I've tried the IP address you sent me, and it cannot be found. I've tried
>>>with LoadFromUrl(), Internet Explorer and PING, and I just can't see the
>>>server at all.
>>
>>Sorry ! It's that I had asked to the Net guy to free our firewall to you and
>>he hadn't done it yet.
>>
>>Now it's done, I hope.
>>
>>Try once more, will you ?
>
>
> Ok, done and found the problem and fixed it. It was a bug in a buffer test
> when HTTP_QUERY_CONTENT_LENGTH failed.
>
> I've uploaded v1.5.
>
I've tested it and it worked fine. Thank you again !
> Regards, |
| Phil Ide
| Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Fri, 04 Feb 2005 15:56:09 +0000Adriano,
>> I've uploaded v1.5.
>>
> I've tested it and it worked fine. Thank you again !
No problem - this function is going to come in very handy later this
year.
Regards,
Phil Ide
***************************************
* Xbase++ FAQ, Libraries and Sources: *
* goto: http://www.idep.org.uk/xbase *
***************************************
Have time to waste? Get Microsoft Windows 3.0! |
| Jose Adriano Baltieri | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Fri, 04 Feb 2005 16:19:59 -0200Phil Ide wrote:
> Adriano,
>
>
>>>I've uploaded v1.5.
>>>
>>
>>I've tested it and it worked fine. Thank you again !
>
>
> No problem - this function is going to come in very handy later this
> year.
Now I'm curious...
>
> Regards, |
| Anand Gupta | Re: LoadFromURL hangs when called twice upon a site that requires authentication
on Sat, 05 Feb 2005 10:58:05 +0530<snip>
> > No problem - this function is going to come in very handy later this
> > year.
>
> Now I'm curious...
We can expect anything and everything from the xbMagic'ian Phil
Anand
NB: Since the bug was found in ASINET LoadFromUrl() too, will someone from
A/S/T aka Alaska issue a PDR for the same ? |