Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iot-device): Allow http proxy to work over http 1.0 #716

Merged
merged 1 commit into from
Feb 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public class ProxiedSSLSocket extends SSLSocket
private String proxyUsername;
private char[] proxyPassword;

private static final String HTTP_VERSION_1_1 = "HTTP/1.1";
private static final String HTTP = "HTTP/";
private static final String HTTP_VERSION_1_1 = HTTP + "1.1";


protected ProxiedSSLSocket(SSLSocketFactory socketFactory, Socket proxySocket, String proxyUsername, char[] proxyPassword)
{
Expand Down Expand Up @@ -122,10 +124,10 @@ private void doTunnelHandshake(Socket tunnel, String host, int port) throws IOEx

//Expects the same http version in the response as the request
String firstLine = connectResponseLines[connectResponseStart];
if (!firstLine.startsWith(HTTP_VERSION_1_1))
if (!firstLine.startsWith(HTTP))
{
tunnel.close();
throw new IOException(String.format("Unable to tunnel through %s:%d. Expected first response line to start with %s, but proxy returns \"%s\"", host, port, HTTP_VERSION_1_1, firstLine));
throw new IOException(String.format("Unable to tunnel through %s:%d. Expected first response line to start with %s, but proxy returns \"%s\"", host, port, HTTP, firstLine));
}

String[] replyStrParts = firstLine.split(" ");
Expand Down