@@ -11,7 +11,7 @@ const char* HttpClient::kContentLengthPrefix = HTTP_HEADER_CONTENT_LENGTH ": ";
11
11
12
12
HttpClient::HttpClient (Client& aClient, const char * aServerName, uint16_t aServerPort)
13
13
: iClient(&aClient), iServerName(aServerName), iServerAddress(), iServerPort(aServerPort),
14
- iConnectionClose(true )
14
+ iConnectionClose(true ), iSendDefaultRequestHeaders( true )
15
15
{
16
16
resetState ();
17
17
}
@@ -23,7 +23,7 @@ HttpClient::HttpClient(Client& aClient, const String& aServerName, uint16_t aSer
23
23
24
24
HttpClient::HttpClient (Client& aClient, const IPAddress& aServerAddress, uint16_t aServerPort)
25
25
: iClient(&aClient), iServerName(NULL ), iServerAddress(aServerAddress), iServerPort(aServerPort),
26
- iConnectionClose(true )
26
+ iConnectionClose(true ), iSendDefaultRequestHeaders( true )
27
27
{
28
28
resetState ();
29
29
}
@@ -49,6 +49,11 @@ void HttpClient::connectionKeepAlive()
49
49
iConnectionClose = false ;
50
50
}
51
51
52
+ void HttpClient::noDefaultRequestHeaders ()
53
+ {
54
+ iSendDefaultRequestHeaders = false ;
55
+ }
56
+
52
57
void HttpClient::beginRequest ()
53
58
{
54
59
iState = eRequestStarted;
@@ -120,20 +125,23 @@ int HttpClient::sendInitialHeaders(const char* aURLPath, const char* aHttpMethod
120
125
121
126
iClient->print (aURLPath);
122
127
iClient->println (" HTTP/1.1" );
123
- // The host header, if required
124
- if (iServerName)
128
+ if (iSendDefaultRequestHeaders)
125
129
{
126
- iClient->print (" Host: " );
127
- iClient->print (iServerName);
128
- if (iServerPort != kHttpPort )
130
+ // The host header, if required
131
+ if (iServerName)
129
132
{
130
- iClient->print (" :" );
131
- iClient->print (iServerPort);
133
+ iClient->print (" Host: " );
134
+ iClient->print (iServerName);
135
+ if (iServerPort != kHttpPort )
136
+ {
137
+ iClient->print (" :" );
138
+ iClient->print (iServerPort);
139
+ }
140
+ iClient->println ();
132
141
}
133
- iClient->println ();
142
+ // And user-agent string
143
+ sendHeader (HTTP_HEADER_USER_AGENT, kUserAgent );
134
144
}
135
- // And user-agent string
136
- sendHeader (HTTP_HEADER_USER_AGENT, kUserAgent );
137
145
138
146
if (iConnectionClose)
139
147
{
0 commit comments