mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-29 12:16:48 +03:00
allow change of User-Agent
This commit is contained in:
parent
cc1fccff4a
commit
20e238a4ca
@ -41,6 +41,8 @@ httpClient::httpClient() {
|
|||||||
_reuse = false;
|
_reuse = false;
|
||||||
_https = false;
|
_https = false;
|
||||||
|
|
||||||
|
_userAgent = "ESP8266httpClient";
|
||||||
|
|
||||||
_headerKeysCount = 0;
|
_headerKeysCount = 0;
|
||||||
_currentHeaders = NULL;
|
_currentHeaders = NULL;
|
||||||
|
|
||||||
@ -210,6 +212,15 @@ void httpClient::setReuse(bool reuse) {
|
|||||||
_reuse = reuse;
|
_reuse = reuse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set User Agent
|
||||||
|
* @param userAgent const char *
|
||||||
|
*/
|
||||||
|
void httpClient::setUserAgent(const char * userAgent) {
|
||||||
|
_userAgent = userAgent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* send a GET request
|
* send a GET request
|
||||||
* @return http code
|
* @return http code
|
||||||
@ -502,9 +513,10 @@ bool httpClient::sendHeader(const char * type) {
|
|||||||
if(!connected()) {
|
if(!connected()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String header = String(type) + " " + _url + " HTTP/1.1\r\n"
|
String header = String(type) + " " + _url + " HTTP/1.1\r\n"
|
||||||
"Host: " + _host + "\r\n"
|
"Host: " + _host + "\r\n"
|
||||||
"User-Agent: ESP8266httpClient\r\n"
|
"User-Agent: " + _userAgent + "\r\n"
|
||||||
"Connection: ";
|
"Connection: ";
|
||||||
|
|
||||||
if(_reuse) {
|
if(_reuse) {
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#ifndef ESP8266HTTPCLIENT_H_
|
#ifndef ESP8266HTTPCLIENT_H_
|
||||||
#define ESP8266HTTPCLIENT_H_
|
#define ESP8266HTTPCLIENT_H_
|
||||||
|
|
||||||
#define DEBUG_HTTPCLIENT(...) Serial1.printf( __VA_ARGS__ )
|
//#define DEBUG_HTTPCLIENT(...) Serial1.printf( __VA_ARGS__ )
|
||||||
|
|
||||||
#ifndef DEBUG_HTTPCLIENT
|
#ifndef DEBUG_HTTPCLIENT
|
||||||
#define DEBUG_HTTPCLIENT(...)
|
#define DEBUG_HTTPCLIENT(...)
|
||||||
@ -59,6 +59,7 @@ class httpClient {
|
|||||||
bool connected(void);
|
bool connected(void);
|
||||||
|
|
||||||
void setReuse(bool reuse); /// keep-alive
|
void setReuse(bool reuse); /// keep-alive
|
||||||
|
void setUserAgent(const char * userAgent);
|
||||||
|
|
||||||
/// request handling
|
/// request handling
|
||||||
int GET();
|
int GET();
|
||||||
@ -105,7 +106,8 @@ class httpClient {
|
|||||||
bool _https;
|
bool _https;
|
||||||
String _httpsFingerprint;
|
String _httpsFingerprint;
|
||||||
|
|
||||||
String _Headers;
|
String _Headers;
|
||||||
|
String _userAgent;
|
||||||
|
|
||||||
/// Response handling
|
/// Response handling
|
||||||
RequestArgument* _currentHeaders;
|
RequestArgument* _currentHeaders;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user