HTTPSocket times out, but same string works in Safari address bar

I’m generating an XML string in Xojo to communicate with Filemaker. When the string supplies user:password in the XML string to access an account requiring that, the HTTPSocket times out. But if the same string is entered in Safari’s address bar, all works fine.

The following example times out when Sock.Get is called:
Sub ConnectToFM (sock as httpsocket) as string
dim page, A as string
A=“http://admin:xxxx@192.168.1.20:80/fmi/xml/fmresultset.xml?-db=inspectiondata&-lay=formationtest&-script=GetUser&-max=all&-findall=
page=sock.Get(A,5)

But if the A string is entered in Safari’s address bar, it works as expected.

And if A=“http://192.168.1.20:80/fmi/xml/fmresultset.xml?-db=inspectiondata&-lay=formationtest&-script=GetUser&-max=all&-findall=”,
and Filemaker guest account is open, sock.Get(A,5) does work.

What might Safari be doing differently than HTTPSocket that allows it to work when Filemaker requires authorization?

  1. Setting a user agent
  2. If it’s a classic HTTPSocket, it could be that it’s http/1.0
  3. Classic sockets don’t automatically handle redirects

Thank, that was quick!
Yes, the code was written over 10 years ago, so I expect it is 1.0. It had been working fine, until I decided I wanted to close Filemaker’s guest account.
So I need to rewrite the code to use Xojo-Net.HTTPSocket if I want to use an authorized account, which is what you mean by redirect?

[quote=351580:@David Graham]Thank, that was quick!
Yes, the code was written over 10 years ago, so I expect it is 1.0. It had been working fine, until I decided I wanted to close Filemaker’s guest account.
So I need to rewrite the code to use Xojo-Net.HTTPSocket if I want to use an authorized account, which is what you mean by redirect?[/quote]
Redirect is a response code of 301 or 302 telling you that the page has moved and what the new url is in the Location header.

Authorization does work in the old sockets, but if the site requires http/1.1, you’ll have to use the Xojo.Net.HTTPSocket.

[quote=351578:@David Graham]What might Safari be doing differently than HTTPSocket that allows it to work when Filemaker requires authorization?[/quote] Most web browsers will automatically take the username/password from a typed URL and use them to set the Authorization header when making the request.

Sub ConnectToFM (sock as httpsocket) as string dim page, A as string A="http://192.168.1.20:80/fmi/xml/fmresultset.xml?-db=inspectiondata&-lay=formationtest&-script=GetUser&-max=all&-findall=" sock.SetRequestHeader("Authorization", "Basic " + EncodeBase64("admin" + ":" + "xxxx")) page=sock.Get(A,5)

Thank-you Andrew, that did the trick. I didn’t have to use Xojo.net.HTMLsocket.