Advertisement

301 errors

Started by July 20, 2005 03:19 PM
1 comment, last by Halo7 19 years, 7 months ago
I am trying to use some winsock code to download the HTML from www.supanet.com but all I keep getting are 301 errors directing me around in circles. Can anyone try using their own code to download the HTML and explain exactly what URL they used to get it? I must be going wrong somewhere! The reason I want to do this is that they host my website and I want to put a data file on my website to test my application for downloading data. Thanks.
10.3.2 301 Moved Permanently

The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise.

The new permanent URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).

If the 301 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

Note: When automatically redirecting a POST request after
receiving a 301 status code, some existing HTTP/1.0 user agents
will erroneously change it into a GET request.
Advertisement
Quote:
Original post by paulbird
I am trying to use some winsock code to download the HTML from www.supanet.com but all I keep getting are 301 errors directing me around in circles.

Can anyone try using their own code to download the HTML and explain exactly what URL they used to get it? I must be going wrong somewhere!

The reason I want to do this is that they host my website and I want to put a data file on my website to test my application for downloading data.

Thanks.


Supanet.com appears to be using virtual hosts. Meaning more than 1 domain is hosted on the same server. With this in mind, imagine this web server getting the following request:

GET /index.html HTTP/1.0\r\n
\r\n

Most, if not all, of the virtual hosts will have a /index.html so how does the server know what /index.html you mean? You need to specify the host in the request. How do you do that? The Host header field. So the request becomes:

GET /index.html HTTP/1.1\r\n
Host: www.supanet.com\r\n
\r\n

Now you get /index.html for the host www.supanet.com.

Also, on a side note, 3xx response codes are not error codes. 4xx and 5xx are.

-Halo7

This topic is closed to new replies.

Advertisement