Skip to content

Commit e3a6c20

Browse files
committed
Remove proxy support (for now)
1 parent ad9bd94 commit e3a6c20

File tree

2 files changed

+7
-87
lines changed

2 files changed

+7
-87
lines changed

HttpClient.cpp

Lines changed: 7 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,16 @@
44

55
#include "HttpClient.h"
66
#include "b64.h"
7-
#ifdef PROXY_ENABLED // currently disabled as introduces dependency on Dns.h in Ethernet
8-
#include <Dns.h>
9-
#endif
107

118
// Initialize constants
129
const char* HttpClient::kUserAgent = "Arduino/2.2.0";
1310
const char* HttpClient::kContentLengthPrefix = HTTP_HEADER_CONTENT_LENGTH ": ";
1411

15-
#ifdef PROXY_ENABLED // currently disabled as introduces dependency on Dns.h in Ethernet
16-
HttpClient::HttpClient(Client& aClient, const char* aProxy, uint16_t aProxyPort)
17-
: iClient(&aClient), iProxyPort(aProxyPort)
18-
{
19-
resetState();
20-
if (aProxy)
21-
{
22-
// Resolve the IP address for the proxy
23-
DNSClient dns;
24-
dns.begin(Ethernet.dnsServerIP());
25-
// Not ideal that we discard any errors here, but not a lot we can do in the ctor
26-
// and we'll get a connect error later anyway
27-
(void)dns.getHostByName(aProxy, iProxyAddress);
28-
}
29-
}
30-
#else
3112
HttpClient::HttpClient(Client& aClient)
3213
: iClient(&aClient)
3314
{
3415
resetState();
3516
}
36-
#endif
3717

3818
void HttpClient::resetState()
3919
{
@@ -64,27 +44,12 @@ int HttpClient::startRequest(const char* aServerName, uint16_t aServerPort, cons
6444
return HTTP_ERROR_API;
6545
}
6646

67-
#ifdef PROXY_ENABLED
68-
if (iProxyPort)
69-
{
70-
if (!iClient->connect(iProxyAddress, iProxyPort) > 0)
71-
{
72-
#ifdef LOGGING
73-
Serial.println("Proxy connection failed");
74-
#endif
75-
return HTTP_ERROR_CONNECTION_FAILED;
76-
}
77-
}
78-
else
79-
#endif
47+
if (!iClient->connect(aServerName, aServerPort) > 0)
8048
{
81-
if (!iClient->connect(aServerName, aServerPort) > 0)
82-
{
8349
#ifdef LOGGING
84-
Serial.println("Connection failed");
50+
Serial.println("Connection failed");
8551
#endif
86-
return HTTP_ERROR_CONNECTION_FAILED;
87-
}
52+
return HTTP_ERROR_CONNECTION_FAILED;
8853
}
8954

9055
// Now we're connected, send the first part of the request
@@ -107,27 +72,12 @@ int HttpClient::startRequest(const IPAddress& aServerAddress, const char* aServe
10772
return HTTP_ERROR_API;
10873
}
10974

110-
#ifdef PROXY_ENABLED
111-
if (iProxyPort)
75+
if (!iClient->connect(aServerAddress, aServerPort) > 0)
11276
{
113-
if (!iClient->connect(iProxyAddress, iProxyPort) > 0)
114-
{
11577
#ifdef LOGGING
116-
Serial.println("Proxy connection failed");
78+
Serial.println("Connection failed");
11779
#endif
118-
return HTTP_ERROR_CONNECTION_FAILED;
119-
}
120-
}
121-
else
122-
#endif
123-
{
124-
if (!iClient->connect(aServerAddress, aServerPort) > 0)
125-
{
126-
#ifdef LOGGING
127-
Serial.println("Connection failed");
128-
#endif
129-
return HTTP_ERROR_CONNECTION_FAILED;
130-
}
80+
return HTTP_ERROR_CONNECTION_FAILED;
13181
}
13282

13383
// Now we're connected, send the first part of the request
@@ -150,28 +100,7 @@ int HttpClient::sendInitialHeaders(const char* aServerName, IPAddress aServerIP,
150100
// Send the HTTP command, i.e. "GET /somepath/ HTTP/1.0"
151101
iClient->print(aHttpMethod);
152102
iClient->print(" ");
153-
#ifdef PROXY_ENABLED
154-
if (iProxyPort)
155-
{
156-
// We're going through a proxy, send a full URL
157-
iClient->print("http://");
158-
if (aServerName)
159-
{
160-
// We've got a server name, so use it
161-
iClient->print(aServerName);
162-
}
163-
else
164-
{
165-
// We'll have to use the IP address
166-
iClient->print(aServerIP);
167-
}
168-
if (aPort != kHttpPort)
169-
{
170-
iClient->print(":");
171-
iClient->print(aPort);
172-
}
173-
}
174-
#endif
103+
175104
iClient->print(aURLPath);
176105
iClient->println(" HTTP/1.1");
177106
// The host header, if required

HttpClient.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ class HttpClient : public Client
4444
// FIXME Write longer API request, using port and user-agent, example
4545
// FIXME Update tempToPachube example to calculate Content-Length correctly
4646

47-
#ifdef PROXY_ENABLED // currently disabled as introduces dependency on Dns.h in Ethernet
48-
HttpClient(Client& aClient, const char* aProxy =NULL, uint16_t aProxyPort =0);
49-
#else
5047
HttpClient(Client& aClient);
51-
#endif
5248

5349
/** Start a more complex request.
5450
Use this when you need to send additional headers in the request,
@@ -440,11 +436,6 @@ class HttpClient : public Client
440436
int iBodyLengthConsumed;
441437
// How far through a Content-Length header prefix we are
442438
const char* iContentLengthPtr;
443-
#ifdef PROXY_ENABLED
444-
// Address of the proxy to use, if we're using one
445-
IPAddress iProxyAddress;
446-
uint16_t iProxyPort;
447-
#endif
448439
uint32_t iHttpResponseTimeout;
449440
};
450441

0 commit comments

Comments
 (0)