301 error using a documentation example !

To be completely honest, I turned my attention to the provided example because I have this error in one of my projects…

The code:

Dim socket1 As New HTTPSocket Dim data As String = socket1.Get("http://www.xojo.com/", 30)

The returned error:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">?<html><head>?<title>301 Moved Permanently</title>?</head><body>?<h1>Moved Permanently</h1>?<p>The document has moved <a href="https://www.xojo.com/">here</a>.</p>?</body></html>?

The replacement character is in the original string.

The example comes from HTTPSocket .

I forgot to say that the provided URL (here: http://www.xojo.com/) is valid in a browser (HTMLViever based or Firefox, Safari, etc.) The error is elsewhere.

HTTP error 301 simply means that the content you have requested has been moved to another url. If you were to check the status in the HeadersReceived event and in the event of 301 or 302, you can read the Location header to get the new url you should be requesting.

Thank you for your answer Greg.

Unfortunately, I do not understand… imagine that the code I shared above is the only code in a brand new project… (MsgBox data have to be added to be complete) in a PushButton.

I investigated a little bit and the value in the returned header (Location) is… https://www.xojo.com/. If I use that value, I get the same redirection error string.
I get the same result if I use https://www.xojo.com/ in Get…

In four words: I do not understand (or three: I am lost).

You shouldn’t. The first url is


The redirected version is the secure version:


Now it’s entirely possible that there is a second redirect to yet another url, perhaps with a subdirectory attached.

Which is very often the case. But you can “catch” the redirect and your code can act acordingly, using code from this Thread.

Here’s my latest code:

[code] Dim socket1 As New HTTPSocket
Dim data As String
Dim my_Headers As InternetHeaders

TF_URL.Text = “https://www.xojo.com/

my_Headers = socket1.GetHeaders(TF_URL.Text,30)

TA.Text = my_Headers.Value(“Location”,0)[/code]

I get in TA:


Now I will check the shared project.

The shared project works fine (with my own url). I had no doubt about that, but… I needed to load the current Xojo version…

Now: I cannot use it in my project or I must use Xojo demo version (my license # does not support the new (iOS) framework).

It looks like xojo.com is rejecting connections that use older versions of SSL/TLS.

e.g. this works for me:

Dim socket1 As New HTTPSecureSocket socket1.ConnectionType = SSLSocket.TLSv12 Dim data As String = socket1.Get("http://www.xojo.com/", 30)

Not only xojo.com. As I wrote in the original question, I come there because I got that in a project (but with a different web location).

I try your code and… IT WORKS ! As is… I only changed the URL (Xojo) to my own (one of those I use in the original project).

NICE… I just have to change my original project (I hope so) and the business will resums as usual ! :wink:

Good catch Andrew ! Thanks a lot !

I noticed the difference in the Classic and new Framework HTTPSocket (1 vs 1.1), but since the documentation says nothing… (for once that I noticed something).

Many, but not all, HTTPS web sites will exhibit this problem when using Xojo’s HTTPSecureSocket class. This started happening in 2014 as a result of the response to the “Heartbleed” bug, which affects servers that use OpenSSL. These servers have been reconfigured to refuse connections that use TLSv1.0 and older, but HTTPSecureSocket uses TLSv1.0 as its default.


thank you for the tip. I was able to do a skeleton of what I wanted to do (a method replacement for the part that does not worked in the original project).

The code needs some refinements, but it works fine.