add user agent header

fixes #628
This commit is contained in:
Konstantin Käfer
2014-12-08 10:56:00 +01:00
parent de098591c5
commit 1f91be988b
4 changed files with 7 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ namespace mbgl {
namespace util {
extern const float tileSize;
extern const char *userAgent;
}

View File

@@ -2,6 +2,7 @@
#include <mbgl/util/std.hpp>
#include <mbgl/util/parsedate.h>
#include <mbgl/util/time.hpp>
#include <mbgl/util/constants.hpp>
#include <uv.h>
@@ -40,6 +41,8 @@ void HTTPRequestBaton::start(const util::ptr<HTTPRequestBaton> &ptr) {
}
}
[request addValue:@(util::userAgent) forHTTPHeaderField:@"User-Agent"];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *res, NSError *error) {
if (error) {

View File

@@ -3,6 +3,7 @@
#include <mbgl/util/time.hpp>
#include <mbgl/util/string.hpp>
#include <mbgl/util/std.hpp>
#include <mbgl/util/constants.hpp>
#include <uv.h>
#include <curl/curl.h>
@@ -444,6 +445,7 @@ void start_request(void *const ptr) {
curl_easy_setopt(context->handle, CURLOPT_HEADERFUNCTION, curl_header_cb);
curl_easy_setopt(context->handle, CURLOPT_HEADERDATA, &context->baton->response);
curl_easy_setopt(context->handle, CURLOPT_ACCEPT_ENCODING, "gzip, deflate");
curl_easy_setopt(context->handle, CURLOPT_USERAGENT, util::userAgent);
curl_easy_setopt(context->handle, CURLOPT_SHARE, share);
// Start requesting the information.

View File

@@ -1,6 +1,7 @@
#include <mbgl/util/constants.hpp>
const float mbgl::util::tileSize = 512.0f;
const char *mbgl::util::userAgent = "MapboxGL/1.0 (+https://mapbox.com/mapbox-gl/)";
#if defined(DEBUG)
const bool mbgl::debug::tileParseWarnings = false;