Match headers case-insensitively.
This commit is contained in:
parent
2fa3bff89c
commit
d43b1c72db
|
@ -20,6 +20,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <algorithm>
|
||||||
#include <Poco/Net/FilePartSource.h>
|
#include <Poco/Net/FilePartSource.h>
|
||||||
#include <Poco/URI.h>
|
#include <Poco/URI.h>
|
||||||
#include "version.hpp"
|
#include "version.hpp"
|
||||||
|
@ -265,10 +266,13 @@ return_call API::register_app2(const string &client_id,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string API::get_header(const std::string &header) const
|
const string API::get_header(std::string header) const
|
||||||
{
|
{
|
||||||
string headers;
|
string headers;
|
||||||
_http.get_headers(headers);
|
_http.get_headers(headers);
|
||||||
|
std::transform(headers.begin(), headers.end(), headers.begin(), ::tolower);
|
||||||
|
std::transform(header.begin(), header.end(), header.begin(), ::tolower);
|
||||||
|
|
||||||
size_t startpos = headers.find(header + ':');
|
size_t startpos = headers.find(header + ':');
|
||||||
if (startpos != std::string::npos)
|
if (startpos != std::string::npos)
|
||||||
{
|
{
|
||||||
|
|
|
@ -411,7 +411,7 @@ namespace Mastodon
|
||||||
string &access_token);
|
string &access_token);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Gets the header from the last answer.
|
* @brief Gets the header from the last answer. Case insensitive.
|
||||||
*
|
*
|
||||||
* @param header The header to get
|
* @param header The header to get
|
||||||
*
|
*
|
||||||
|
@ -419,7 +419,7 @@ namespace Mastodon
|
||||||
*
|
*
|
||||||
* @since before 0.11.0
|
* @since before 0.11.0
|
||||||
*/
|
*/
|
||||||
const string get_header(const string &header) const;
|
const string get_header(string header) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Turn exceptions on or off. Defaults to off.
|
* @brief Turn exceptions on or off. Defaults to off.
|
||||||
|
|
Reference in New Issue