I seem to be experiencing issues just trying a simple Get method of the HTTPSocket Class.

I am accessing a Microsoft base server. The info I get for the Header info is:

Code: 302
Server: Microsoft-IIS/5.1
Date: Tue, 06 May 2014 15:48:14 GMT
X-Powered-By: ASP.NET
Connection: close
Location: WEBDAL.asp?WCI=DAL&WCU=xxxxxxxxxxxx
Content-Length: 121
Content-Type: text/html
Expires: Tue, 06 May 2014 15:48:14 GMT
Cache-control: private

How do I get around just trying to use the Get method and getting the string returned?


It looks like it has worked. You have a response. What are you expecting?

I am expecting some status info and a message stating login was successful. I cant post the actual link but my code is just basically an httpsocket.get method and thats it.

Your response was Code 302.

The URL you were accessing is a redirect.

How do I handle that? I cannot even get the pagereceived event or any other to fire so I can capture something to try to resolve this.

The documentation and examples as usual suck.

[quote=86081:@Tom Russell]How do I handle that? I cannot even get the pagereceived event or any other to fire so I can capture something to try to resolve this.

The documentation and examples as usual suck.[/quote]

This will be down to the server. You are probably correctly logging in and then the server is redirecting you to a logged in page. However if this is a log in page I suspect you will also need to be using the HTTPSecureSocket not HTTPSocket which will be using port 443 rather than port 80.

it works with port 80 just fine.

What event would be used with the HTTPSocket class to get the redirect url?

You would probably have to get the response with
It looks like the content-length is 121 which may very well be the redirect url.

Not an HTTP expert though, so I don’t have any example code for you. looks like it can actually return a string.
See what’s inside the string of your request?

If the HTTPStatusCode is 302 or 3xx then it is a redirect. The redirect path is the Location’s value in the PageHeaders. In your case it is: WEBDAL.asp?WCI=DAL&WCU=xxxxxxxxxxxx

As you can see it is not a complete URL, so you have to construct it. The usual way to construct a redirect url is + location’s value (WEBDAL.asp?WCI=DAL&WCU=xxxxxxxxxxxx)

When I handled 302s in the past it was the location field in the response headers that’s the new url. And sometimes it’d redirected 3 or 4 times before getting the actual content.

Thanks HTTP experts :slight_smile:

Yes I see that now, thanks.

I have the redirect working fine and all but this is what happens.

I get the login page and get logged in when passing the credentials in the url. Its successful and I have checked this. Once that is done I use another url for the same site and pass in info that gives me a redirect as well. I am unable to get access at this point because I get logged out somehow and have no idea why.

Is there something else I need to do to keep me logged in so I can access the results of the next url I am doing? I have checked with the maintainer of the site and there is no issue on their side. I can do both url’s in the browser and it all works as expected.


Save the cookies. The PageHeaders after the login should have one or more “Set-Cookie” values. You should add them to an array of strings, and then when you want to use HTTPSocket, while logged in, you have to add cookie headers:

http.SetRequestHeader(“Cookie”,Join(cookies(),"; "))

Check the docs for HTTPSocket for more info