Commit 19d2864c authored by Max Kellermann's avatar Max Kellermann Committed by Max Kellermann

lib/curl/Headers: central type definition for the header map

parent 29e3a17f
...@@ -82,7 +82,7 @@ class CurlInputStream final : public AsyncInputStream, CurlResponseHandler { ...@@ -82,7 +82,7 @@ class CurlInputStream final : public AsyncInputStream, CurlResponseHandler {
public: public:
template<typename I> template<typename I>
CurlInputStream(EventLoop &event_loop, const char *_url, CurlInputStream(EventLoop &event_loop, const char *_url,
const std::multimap<std::string, std::string> &headers, const Curl::Headers &headers,
I &&_icy, I &&_icy,
Mutex &_mutex); Mutex &_mutex);
...@@ -92,7 +92,7 @@ public: ...@@ -92,7 +92,7 @@ public:
CurlInputStream &operator=(const CurlInputStream &) = delete; CurlInputStream &operator=(const CurlInputStream &) = delete;
static InputStreamPtr Open(const char *url, static InputStreamPtr Open(const char *url,
const std::multimap<std::string, std::string> &headers, const Curl::Headers &headers,
Mutex &mutex); Mutex &mutex);
private: private:
...@@ -131,8 +131,7 @@ private: ...@@ -131,8 +131,7 @@ private:
void SeekInternal(offset_type new_offset); void SeekInternal(offset_type new_offset);
/* virtual methods from CurlResponseHandler */ /* virtual methods from CurlResponseHandler */
void OnHeaders(unsigned status, void OnHeaders(unsigned status, Curl::Headers &&headers) override;
std::multimap<std::string, std::string> &&headers) override;
void OnData(ConstBuffer<void> data) override; void OnData(ConstBuffer<void> data) override;
void OnEnd() override; void OnEnd() override;
void OnError(std::exception_ptr e) noexcept override; void OnError(std::exception_ptr e) noexcept override;
...@@ -227,7 +226,7 @@ WithConvertedTagValue(const char *uri, const char *value, F &&f) noexcept ...@@ -227,7 +226,7 @@ WithConvertedTagValue(const char *uri, const char *value, F &&f) noexcept
void void
CurlInputStream::OnHeaders(unsigned status, CurlInputStream::OnHeaders(unsigned status,
std::multimap<std::string, std::string> &&headers) Curl::Headers &&headers)
{ {
assert(GetEventLoop().IsInside()); assert(GetEventLoop().IsInside());
assert(!postponed_exception); assert(!postponed_exception);
...@@ -391,7 +390,7 @@ input_curl_finish() noexcept ...@@ -391,7 +390,7 @@ input_curl_finish() noexcept
template<typename I> template<typename I>
inline inline
CurlInputStream::CurlInputStream(EventLoop &event_loop, const char *_url, CurlInputStream::CurlInputStream(EventLoop &event_loop, const char *_url,
const std::multimap<std::string, std::string> &headers, const Curl::Headers &headers,
I &&_icy, I &&_icy,
Mutex &_mutex) Mutex &_mutex)
:AsyncInputStream(event_loop, _url, _mutex, :AsyncInputStream(event_loop, _url, _mutex,
...@@ -491,7 +490,7 @@ CurlInputStream::DoSeek(offset_type new_offset) ...@@ -491,7 +490,7 @@ CurlInputStream::DoSeek(offset_type new_offset)
inline InputStreamPtr inline InputStreamPtr
CurlInputStream::Open(const char *url, CurlInputStream::Open(const char *url,
const std::multimap<std::string, std::string> &headers, const Curl::Headers &headers,
Mutex &mutex) Mutex &mutex)
{ {
auto icy = std::make_shared<IcyMetaDataParser>(); auto icy = std::make_shared<IcyMetaDataParser>();
...@@ -510,8 +509,7 @@ CurlInputStream::Open(const char *url, ...@@ -510,8 +509,7 @@ CurlInputStream::Open(const char *url,
} }
InputStreamPtr InputStreamPtr
OpenCurlInputStream(const char *uri, OpenCurlInputStream(const char *uri, const Curl::Headers &headers,
const std::multimap<std::string, std::string> &headers,
Mutex &mutex) Mutex &mutex)
{ {
return CurlInputStream::Open(uri, headers, mutex); return CurlInputStream::Open(uri, headers, mutex);
......
...@@ -20,12 +20,10 @@ ...@@ -20,12 +20,10 @@
#ifndef MPD_INPUT_CURL_HXX #ifndef MPD_INPUT_CURL_HXX
#define MPD_INPUT_CURL_HXX #define MPD_INPUT_CURL_HXX
#include "lib/curl/Headers.hxx"
#include "input/Ptr.hxx" #include "input/Ptr.hxx"
#include "thread/Mutex.hxx" #include "thread/Mutex.hxx"
#include <string>
#include <map>
extern const struct InputPlugin input_plugin_curl; extern const struct InputPlugin input_plugin_curl;
/** /**
...@@ -36,8 +34,7 @@ extern const struct InputPlugin input_plugin_curl; ...@@ -36,8 +34,7 @@ extern const struct InputPlugin input_plugin_curl;
* Throws on error. * Throws on error.
*/ */
InputStreamPtr InputStreamPtr
OpenCurlInputStream(const char *uri, OpenCurlInputStream(const char *uri, const Curl::Headers &headers,
const std::multimap<std::string, std::string> &headers,
Mutex &mutex); Mutex &mutex);
#endif #endif
...@@ -164,7 +164,7 @@ QobuzClient::InvokeHandlers() noexcept ...@@ -164,7 +164,7 @@ QobuzClient::InvokeHandlers() noexcept
std::string std::string
QobuzClient::MakeUrl(const char *object, const char *method, QobuzClient::MakeUrl(const char *object, const char *method,
const std::multimap<std::string, std::string> &query) const noexcept const Curl::Headers &query) const noexcept
{ {
assert(!query.empty()); assert(!query.empty());
...@@ -183,7 +183,7 @@ QobuzClient::MakeUrl(const char *object, const char *method, ...@@ -183,7 +183,7 @@ QobuzClient::MakeUrl(const char *object, const char *method,
std::string std::string
QobuzClient::MakeSignedUrl(const char *object, const char *method, QobuzClient::MakeSignedUrl(const char *object, const char *method,
const std::multimap<std::string, std::string> &query) const noexcept const Curl::Headers &query) const noexcept
{ {
assert(!query.empty()); assert(!query.empty());
......
...@@ -23,12 +23,12 @@ ...@@ -23,12 +23,12 @@
#include "QobuzSession.hxx" #include "QobuzSession.hxx"
#include "QobuzLoginRequest.hxx" #include "QobuzLoginRequest.hxx"
#include "lib/curl/Init.hxx" #include "lib/curl/Init.hxx"
#include "lib/curl/Headers.hxx"
#include "thread/Mutex.hxx" #include "thread/Mutex.hxx"
#include "event/DeferEvent.hxx" #include "event/DeferEvent.hxx"
#include "util/IntrusiveList.hxx" #include "util/IntrusiveList.hxx"
#include <memory> #include <memory>
#include <map>
#include <string> #include <string>
class QobuzSessionHandler class QobuzSessionHandler
...@@ -94,10 +94,10 @@ public: ...@@ -94,10 +94,10 @@ public:
QobuzSession GetSession() const; QobuzSession GetSession() const;
std::string MakeUrl(const char *object, const char *method, std::string MakeUrl(const char *object, const char *method,
const std::multimap<std::string, std::string> &query) const noexcept; const Curl::Headers &query) const noexcept;
std::string MakeSignedUrl(const char *object, const char *method, std::string MakeSignedUrl(const char *object, const char *method,
const std::multimap<std::string, std::string> &query) const noexcept; const Curl::Headers &query) const noexcept;
private: private:
void StartLogin(); void StartLogin();
......
...@@ -38,7 +38,7 @@ static constexpr yajl_callbacks qobuz_error_parser_callbacks = { ...@@ -38,7 +38,7 @@ static constexpr yajl_callbacks qobuz_error_parser_callbacks = {
}; };
QobuzErrorParser::QobuzErrorParser(unsigned _status, QobuzErrorParser::QobuzErrorParser(unsigned _status,
const std::multimap<std::string, std::string> &headers) const Curl::Headers &headers)
:YajlResponseParser(&qobuz_error_parser_callbacks, nullptr, this), :YajlResponseParser(&qobuz_error_parser_callbacks, nullptr, this),
status(_status) status(_status)
{ {
......
...@@ -20,11 +20,9 @@ ...@@ -20,11 +20,9 @@
#ifndef QOBUZ_ERROR_PARSER_HXX #ifndef QOBUZ_ERROR_PARSER_HXX
#define QOBUZ_ERROR_PARSER_HXX #define QOBUZ_ERROR_PARSER_HXX
#include "lib/curl/Headers.hxx"
#include "lib/yajl/ResponseParser.hxx" #include "lib/yajl/ResponseParser.hxx"
#include <string>
#include <map>
template<typename T> struct ConstBuffer; template<typename T> struct ConstBuffer;
struct StringView; struct StringView;
...@@ -46,8 +44,7 @@ public: ...@@ -46,8 +44,7 @@ public:
* May throw if there is a formal error in the response * May throw if there is a formal error in the response
* headers. * headers.
*/ */
QobuzErrorParser(unsigned status, QobuzErrorParser(unsigned status, const Curl::Headers &headers);
const std::multimap<std::string, std::string> &headers);
protected: protected:
/* virtual methods from CurlResponseParser */ /* virtual methods from CurlResponseParser */
......
...@@ -77,7 +77,7 @@ QobuzLoginRequest::ResponseParser::GetSession() ...@@ -77,7 +77,7 @@ QobuzLoginRequest::ResponseParser::GetSession()
return std::move(session); return std::move(session);
} }
static std::multimap<std::string, std::string> static Curl::Headers
MakeLoginForm(const char *app_id, MakeLoginForm(const char *app_id,
const char *username, const char *email, const char *username, const char *email,
const char *password, const char *password,
...@@ -85,7 +85,7 @@ MakeLoginForm(const char *app_id, ...@@ -85,7 +85,7 @@ MakeLoginForm(const char *app_id,
{ {
assert(username != nullptr || email != nullptr); assert(username != nullptr || email != nullptr);
std::multimap<std::string, std::string> form{ Curl::Headers form{
{"app_id", app_id}, {"app_id", app_id},
{"password", password}, {"password", password},
{"device_manufacturer_id", device_manufacturer_id}, {"device_manufacturer_id", device_manufacturer_id},
...@@ -134,8 +134,7 @@ QobuzLoginRequest::~QobuzLoginRequest() noexcept ...@@ -134,8 +134,7 @@ QobuzLoginRequest::~QobuzLoginRequest() noexcept
} }
std::unique_ptr<CurlResponseParser> std::unique_ptr<CurlResponseParser>
QobuzLoginRequest::MakeParser(unsigned status, QobuzLoginRequest::MakeParser(unsigned status, Curl::Headers &&headers)
std::multimap<std::string, std::string> &&headers)
{ {
if (status != 200) if (status != 200)
return std::make_unique<QobuzErrorParser>(status, headers); return std::make_unique<QobuzErrorParser>(status, headers);
......
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
private: private:
/* virtual methods from DelegateCurlResponseHandler */ /* virtual methods from DelegateCurlResponseHandler */
std::unique_ptr<CurlResponseParser> MakeParser(unsigned status, std::unique_ptr<CurlResponseParser> MakeParser(unsigned status,
std::multimap<std::string, std::string> &&headers) override; Curl::Headers &&headers) override;
void FinishParser(std::unique_ptr<CurlResponseParser> p) override; void FinishParser(std::unique_ptr<CurlResponseParser> p) override;
/* virtual methods from CurlResponseHandler */ /* virtual methods from CurlResponseHandler */
......
...@@ -99,8 +99,7 @@ QobuzTagScanner::~QobuzTagScanner() noexcept ...@@ -99,8 +99,7 @@ QobuzTagScanner::~QobuzTagScanner() noexcept
} }
std::unique_ptr<CurlResponseParser> std::unique_ptr<CurlResponseParser>
QobuzTagScanner::MakeParser(unsigned status, QobuzTagScanner::MakeParser(unsigned status, Curl::Headers &&headers)
std::multimap<std::string, std::string> &&headers)
{ {
if (status != 200) if (status != 200)
return std::make_unique<QobuzErrorParser>(status, headers); return std::make_unique<QobuzErrorParser>(status, headers);
......
...@@ -49,7 +49,7 @@ public: ...@@ -49,7 +49,7 @@ public:
private: private:
/* virtual methods from DelegateCurlResponseHandler */ /* virtual methods from DelegateCurlResponseHandler */
std::unique_ptr<CurlResponseParser> MakeParser(unsigned status, std::unique_ptr<CurlResponseParser> MakeParser(unsigned status,
std::multimap<std::string, std::string> &&headers) override; Curl::Headers &&headers) override;
void FinishParser(std::unique_ptr<CurlResponseParser> p) override; void FinishParser(std::unique_ptr<CurlResponseParser> p) override;
/* virtual methods from CurlResponseHandler */ /* virtual methods from CurlResponseHandler */
......
...@@ -93,7 +93,7 @@ QobuzTrackRequest::~QobuzTrackRequest() noexcept ...@@ -93,7 +93,7 @@ QobuzTrackRequest::~QobuzTrackRequest() noexcept
std::unique_ptr<CurlResponseParser> std::unique_ptr<CurlResponseParser>
QobuzTrackRequest::MakeParser(unsigned status, QobuzTrackRequest::MakeParser(unsigned status,
std::multimap<std::string, std::string> &&headers) Curl::Headers &&headers)
{ {
if (status != 200) if (status != 200)
return std::make_unique<QobuzErrorParser>(status, headers); return std::make_unique<QobuzErrorParser>(status, headers);
......
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
private: private:
/* virtual methods from DelegateCurlResponseHandler */ /* virtual methods from DelegateCurlResponseHandler */
std::unique_ptr<CurlResponseParser> MakeParser(unsigned status, std::unique_ptr<CurlResponseParser> MakeParser(unsigned status,
std::multimap<std::string, std::string> &&headers) override; Curl::Headers &&headers) override;
void FinishParser(std::unique_ptr<CurlResponseParser> p) override; void FinishParser(std::unique_ptr<CurlResponseParser> p) override;
/* virtual methods from CurlResponseHandler */ /* virtual methods from CurlResponseHandler */
......
/* /*
* Copyright 2008-2021 Max Kellermann <max.kellermann@gmail.com> * Copyright 2008-2022 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -27,14 +27,13 @@ ...@@ -27,14 +27,13 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef CURL_ADAPTER_HXX #pragma once
#define CURL_ADAPTER_HXX
#include "Headers.hxx"
#include <curl/curl.h> #include <curl/curl.h>
#include <cstddef> #include <cstddef>
#include <map>
#include <string>
struct StringView; struct StringView;
class CurlEasy; class CurlEasy;
...@@ -45,7 +44,7 @@ class CurlResponseHandlerAdapter { ...@@ -45,7 +44,7 @@ class CurlResponseHandlerAdapter {
CurlResponseHandler &handler; CurlResponseHandler &handler;
std::multimap<std::string, std::string> headers; Curl::Headers headers;
/** error message provided by libcurl */ /** error message provided by libcurl */
char error_buffer[CURL_ERROR_SIZE]; char error_buffer[CURL_ERROR_SIZE];
...@@ -83,5 +82,3 @@ private: ...@@ -83,5 +82,3 @@ private:
std::size_t size, std::size_t nmemb, std::size_t size, std::size_t nmemb,
void *stream) noexcept; void *stream) noexcept;
}; };
#endif
/* /*
* Copyright (C) 2008-2018 Max Kellermann <max.kellermann@gmail.com> * Copyright 2008-2022 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -34,8 +34,7 @@ ...@@ -34,8 +34,7 @@
#include <utility> #include <utility>
void void
DelegateCurlResponseHandler::OnHeaders(unsigned status, DelegateCurlResponseHandler::OnHeaders(unsigned status, Curl::Headers &&headers)
std::multimap<std::string, std::string> &&headers)
{ {
parser = MakeParser(status, std::move(headers)); parser = MakeParser(status, std::move(headers));
assert(parser); assert(parser);
......
/* /*
* Copyright (C) 2008-2018 Max Kellermann <max.kellermann@gmail.com> * Copyright 2008-2022 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef CURL_DELEGATE_HXX #pragma once
#define CURL_DELEGATE_HXX
#include "Handler.hxx" #include "Handler.hxx"
...@@ -53,7 +52,7 @@ protected: ...@@ -53,7 +52,7 @@ protected:
* CurlResponseParser::OnError()). * CurlResponseParser::OnError()).
*/ */
virtual std::unique_ptr<CurlResponseParser> MakeParser(unsigned status, virtual std::unique_ptr<CurlResponseParser> MakeParser(unsigned status,
std::multimap<std::string, std::string> &&headers) = 0; Curl::Headers &&headers) = 0;
/** /**
* The parser has finished parsing the response body. This * The parser has finished parsing the response body. This
...@@ -64,10 +63,7 @@ protected: ...@@ -64,10 +63,7 @@ protected:
virtual void FinishParser(std::unique_ptr<CurlResponseParser> p) = 0; virtual void FinishParser(std::unique_ptr<CurlResponseParser> p) = 0;
public: public:
void OnHeaders(unsigned status, void OnHeaders(unsigned status, Curl::Headers &&headers) final;
std::multimap<std::string, std::string> &&headers) final;
void OnData(ConstBuffer<void> data) final; void OnData(ConstBuffer<void> data) final;
void OnEnd() final; void OnEnd() final;
}; };
#endif
...@@ -31,8 +31,7 @@ ...@@ -31,8 +31,7 @@
#include "String.hxx" #include "String.hxx"
std::string std::string
EncodeForm(CURL *curl, EncodeForm(CURL *curl, const Curl::Headers &fields) noexcept
const std::multimap<std::string, std::string> &fields) noexcept
{ {
std::string result; std::string result;
......
...@@ -30,17 +30,17 @@ ...@@ -30,17 +30,17 @@
#ifndef CURL_FORM_HXX #ifndef CURL_FORM_HXX
#define CURL_FORM_HXX #define CURL_FORM_HXX
#include "Headers.hxx"
#include <curl/curl.h> #include <curl/curl.h>
#include <string> #include <string>
#include <map>
/** /**
* Encode the given map of form fields to a * Encode the given map of form fields to a
* "application/x-www-form-urlencoded" string. * "application/x-www-form-urlencoded" string.
*/ */
std::string std::string
EncodeForm(CURL *curl, EncodeForm(CURL *curl, const Curl::Headers &fields) noexcept;
const std::multimap<std::string, std::string> &fields) noexcept;
#endif #endif
...@@ -27,14 +27,12 @@ ...@@ -27,14 +27,12 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef CURL_HANDLER_HXX #pragma once
#define CURL_HANDLER_HXX
#include "Headers.hxx"
#include "util/ConstBuffer.hxx" #include "util/ConstBuffer.hxx"
#include <exception> #include <exception>
#include <string>
#include <map>
/** /**
* Asynchronous response handler for a #CurlRequest. * Asynchronous response handler for a #CurlRequest.
...@@ -53,8 +51,7 @@ public: ...@@ -53,8 +51,7 @@ public:
/** /**
* Status line and headers have been received. * Status line and headers have been received.
*/ */
virtual void OnHeaders(unsigned status, virtual void OnHeaders(unsigned status, Curl::Headers &&headers) = 0;
std::multimap<std::string, std::string> &&headers) = 0;
/** /**
* Response body data has been received. * Response body data has been received.
...@@ -75,5 +72,3 @@ public: ...@@ -75,5 +72,3 @@ public:
*/ */
virtual void OnError(std::exception_ptr e) noexcept = 0; virtual void OnError(std::exception_ptr e) noexcept = 0;
}; };
#endif
/*
* Copyright 2020-2021 CM4all GmbH
* All rights reserved.
*
* author: Max Kellermann <mk@cm4all.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <map>
#include <string>
namespace Curl {
using Headers = std::multimap<std::string, std::string>;
} // namespace Curl
...@@ -55,7 +55,7 @@ UPnPDeviceDirectory::Downloader::Destroy() noexcept ...@@ -55,7 +55,7 @@ UPnPDeviceDirectory::Downloader::Destroy() noexcept
void void
UPnPDeviceDirectory::Downloader::OnHeaders(unsigned status, UPnPDeviceDirectory::Downloader::OnHeaders(unsigned status,
std::multimap<std::string, std::string> &&) Curl::Headers &&)
{ {
if (status != 200) { if (status != 200) {
Destroy(); Destroy();
......
...@@ -113,8 +113,7 @@ class UPnPDeviceDirectory final : UpnpCallback { ...@@ -113,8 +113,7 @@ class UPnPDeviceDirectory final : UpnpCallback {
} }
/* virtual methods from CurlResponseHandler */ /* virtual methods from CurlResponseHandler */
void OnHeaders(unsigned status, void OnHeaders(unsigned status, Curl::Headers &&headers) override;
std::multimap<std::string, std::string> &&headers) override;
void OnData(ConstBuffer<void> data) override; void OnData(ConstBuffer<void> data) override;
void OnEnd() override; void OnEnd() override;
void OnError(std::exception_ptr e) noexcept override; void OnError(std::exception_ptr e) noexcept override;
......
...@@ -227,7 +227,7 @@ IsXmlContentType(const char *content_type) noexcept ...@@ -227,7 +227,7 @@ IsXmlContentType(const char *content_type) noexcept
gcc_pure gcc_pure
static bool static bool
IsXmlContentType(const std::multimap<std::string, std::string> &headers) noexcept IsXmlContentType(const Curl::Headers &headers) noexcept
{ {
auto i = headers.find("content-type"); auto i = headers.find("content-type");
return i != headers.end() && IsXmlContentType(i->second.c_str()); return i != headers.end() && IsXmlContentType(i->second.c_str());
...@@ -297,8 +297,7 @@ private: ...@@ -297,8 +297,7 @@ private:
} }
/* virtual methods from CurlResponseHandler */ /* virtual methods from CurlResponseHandler */
void OnHeaders(unsigned status, void OnHeaders(unsigned status, Curl::Headers &&headers) final {
std::multimap<std::string, std::string> &&headers) final {
if (status != 207) if (status != 207)
throw FormatRuntimeError("Status %d from WebDAV server; expected \"207 Multi-Status\"", throw FormatRuntimeError("Status %d from WebDAV server; expected \"207 Multi-Status\"",
status); status);
......
...@@ -41,8 +41,7 @@ public: ...@@ -41,8 +41,7 @@ public:
} }
/* virtual methods from CurlResponseHandler */ /* virtual methods from CurlResponseHandler */
void OnHeaders(unsigned status, void OnHeaders(unsigned status, Curl::Headers &&headers) override {
std::multimap<std::string, std::string> &&headers) override {
fprintf(stderr, "status: %u\n", status); fprintf(stderr, "status: %u\n", status);
for (const auto &i : headers) for (const auto &i : headers)
fprintf(stderr, "%s: %s\n", fprintf(stderr, "%s: %s\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment