storage/curl: move code to IsXmlContentType()
This commit is contained in:
parent
3717fb6c8d
commit
f6b56c9317
@ -247,6 +247,21 @@ ParseU64(const char *s, size_t length)
|
|||||||
return ParseU64(std::string(s, length).c_str());
|
return ParseU64(std::string(s, length).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gcc_pure
|
||||||
|
static bool
|
||||||
|
IsXmlContentType(const char *content_type) noexcept
|
||||||
|
{
|
||||||
|
return strncmp(content_type, "text/xml", 8) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
gcc_pure
|
||||||
|
static bool
|
||||||
|
IsXmlContentType(const std::multimap<std::string, std::string> &headers) noexcept
|
||||||
|
{
|
||||||
|
auto i = headers.find("content-type");
|
||||||
|
return i != headers.end() && IsXmlContentType(i->second.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A WebDAV PROPFIND request. Each "response" element will be passed
|
* A WebDAV PROPFIND request. Each "response" element will be passed
|
||||||
* to OnDavResponse() (to be implemented by a derived class).
|
* to OnDavResponse() (to be implemented by a derived class).
|
||||||
@ -308,9 +323,7 @@ private:
|
|||||||
throw FormatRuntimeError("Status %d from WebDAV server; expected \"207 Multi-Status\"",
|
throw FormatRuntimeError("Status %d from WebDAV server; expected \"207 Multi-Status\"",
|
||||||
status);
|
status);
|
||||||
|
|
||||||
auto i = headers.find("content-type");
|
if (!IsXmlContentType(headers))
|
||||||
if (i == headers.end() ||
|
|
||||||
strncmp(i->second.c_str(), "text/xml", 8) != 0)
|
|
||||||
throw std::runtime_error("Unexpected Content-Type from WebDAV server");
|
throw std::runtime_error("Unexpected Content-Type from WebDAV server");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user