2

I'm using an old programming language (Adobe's Extendscript). It has a simple Socket object to send TCP/IP requests. The following lines always used to work for me:

reply = "";
conn = new Socket;
if (conn.open ("www.freelancebookdesign.com:80")) {
    conn.write ("GET /license.txt HTTP/1.1\nhost: freelancebookdesign.com\n\n");
    reply = conn.read(9999);
    conn.close();
}

But a couple of days ago, my hosting company (Bluehost) migrated my website to a new box (without being asked to do so, or giving advanced warning). Now the same lines above return the following 400 error:

HTTP/1.1 400 Bad Request
Date: Thu, 02 Jul 2020 10:14:48 GMT
Server: Apache
Upgrade: h2,h2c
Connection: Upgrade, close
Accept-Ranges: bytes
host-header: c2hhcmVkLmJsdWVob3N0LmNvbQ==
Content-Length: 130
Content-Type: text/html; charset=UTF-8

I've contacted their customer support, but received a clueless response. I don't know if this is the right place to ask for help, but I would really appreciate it if anyone has any ideas what the issue might be, even if I can just give their customer support some pointers in the right direction. What might be the difference between the old server setup and the new that would be causing this?

Ariel
  • 21
  • 2

3 Answers3

1

According to the response headers, the target server wants you to speak HTTP 2.0, as indicated by

Upgrade: h2,h2c
Connection: Upgrade, close

I think it would be nicer (and more easy to understand) if the sever sent a 426 (Upgrade required) error, but still, the headers suggest you should speak HTTP 2.0 to the server, so your old script won't work.

Lacek
  • 6,585
  • 22
  • 28
  • Thanks, that does look likely. But the Adobe Extendscript socket object is very old and cannot speak HTTP 2.0. Might there be a setting on the new server that would allow it to accept HTTP 1.1 or HTTP 1.0, or be lenient in some way so that it does not reject this request? – Ariel Jul 02 '20 at 14:48
  • Yes, web servers can be configured so, however, it is another question whether your provider wants to configure the servers this way. You should ask them about it. – Lacek Jul 02 '20 at 15:00
  • Do you know what is the change that needs to be made to the server to make this work? – Ariel Jul 02 '20 at 15:28
  • It depends on what kind of webserver is used. – Lacek Jul 03 '20 at 07:23
0

But a couple of days ago, my hosting company (Bluehost) migrated my website to a new box (without being asked to do so, or giving advanced warning). Now the same lines above return the following 400 error:

This is just a hunch but: your website may now be hosted on a different set of IP addresses. It is conceivable that your application is still trying to connect to the previous IP address(es) because of a cached record or an entry in your hosts file, bypassing normal DNS resolution. If that is the case you would need to update the DNS records for your domain name.

Kate
  • 453
  • 3
  • 7
0

The question (and the answer) in the end turn out to be identical to this: https://stackoverflow.com/questions/43574428/have-apache-accept-lf-vs-crlf-in-request-headers

In other words, Adobe's Extendscript Socket will convert any \r\n sequences to plain \n (this is actually mentioned in the Socket object's documentation) unless the Socket object's encoding is set to binary. At a certain point, Apache servers stopped recognizing \n in request headers and demanded \r\n. Changing HttpProtocolOptions to Unsafe is not an option with shared hosting and my provider was unwilling to do this. Therefore the only answer is to rewrite the original code by setting the encoding to Binary.

Ariel
  • 21
  • 2