summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-11-04 06:44:50 -0800
committerKonstantin Käfer <mail@kkaefer.com>2014-11-04 06:44:50 -0800
commit75889d812402ac2b75d891576a1c37cb43c8eaf3 (patch)
tree8b69bc0cab37c694760169a3e35ec9cc6930a1c2 /platform
parentb6c10e44c08fb7cdb16f8be80fc29e8054eafc05 (diff)
downloadqtlocation-mapboxgl-75889d812402ac2b75d891576a1c37cb43c8eaf3.tar.gz
replace strftime_l with our custom formatter
Diffstat (limited to 'platform')
-rw-r--r--platform/default/http_request_baton_curl.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/platform/default/http_request_baton_curl.cpp b/platform/default/http_request_baton_curl.cpp
index 0c3d2b43fc..80eed27677 100644
--- a/platform/default/http_request_baton_curl.cpp
+++ b/platform/default/http_request_baton_curl.cpp
@@ -2,6 +2,7 @@
#include <mbgl/util/uv-messenger.h>
#include <mbgl/util/std.hpp>
#include <mbgl/util/ptr.hpp>
+#include <mbgl/util/time.hpp>
#include <uv.h>
#include <curl/curl.h>
@@ -9,8 +10,6 @@
#include <queue>
#include <cassert>
#include <cstring>
-#include <ctime>
-#include <xlocale.h>
// This file contains code from http://curl.haxx.se/libcurl/c/multi-uv.html:
@@ -369,9 +368,6 @@ void start_request(void *const ptr) {
util::ptr<HTTPRequestBaton> &baton = *baton_guard.get();
assert(baton);
- // Create a C locale
- static locale_t locale = newlocale(LC_ALL_MASK, nullptr, nullptr);
-
CURL *handle = nullptr;
if (!handles.empty()) {
handle = handles.front();
@@ -390,11 +386,9 @@ void start_request(void *const ptr) {
const std::string header = std::string("If-None-Match: ") + baton->response->etag;
context->headers = curl_slist_append(context->headers, header.c_str());
} else if (baton->response->modified) {
- const time_t modified = baton->response->modified;
- struct tm *timeinfo = std::gmtime(&modified);
- char buffer[64];
- strftime_l(buffer, 64, "If-Modified-Since: %a, %d %b %Y %H:%M:%S GMT", timeinfo, locale);
- context->headers = curl_slist_append(context->headers, buffer);
+ const std::string time = std::string("If-Modified-Since: ") +
+ util::rfc1123(baton->response->modified);
+ context->headers = curl_slist_append(context->headers, time.c_str());
}
}