Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quell some warnings #10023

Merged
merged 2 commits into from
Jun 23, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 20 additions & 6 deletions xbmc/network/WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,23 @@ CWebServer::CWebServer()
#endif
}

static MHD_Response* create_response(size_t size, void* data, int free, int copy)

This comment was marked as spam.

{
#if (MHD_VERSION >= 0x00094001)
MHD_ResponseMemoryMode mode = MHD_RESPMEM_PERSISTENT;
if (copy)
mode = MHD_RESPMEM_MUST_COPY;
else if (free)
mode = MHD_RESPMEM_MUST_FREE;
return MHD_create_response_from_buffer(0, nullptr, mode);
#else
return MHD_create_response_from_data(0, nullptr, free, copy);

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

#endif
}

int CWebServer::AskForAuthentication(struct MHD_Connection *connection) const
{
struct MHD_Response *response = MHD_create_response_from_data(0, nullptr, MHD_NO, MHD_NO);
struct MHD_Response *response = create_response(0, nullptr, MHD_NO, MHD_NO);
if (!response)
{
CLog::Log(LOGERROR, "CWebServer[%hu]: unable to create HTTP Unauthorized response", m_port);
Expand Down Expand Up @@ -284,7 +298,7 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti
ifModifiedSinceDate.SetFromRFC1123DateTime(ifModifiedSince) &&
lastModified.GetAsUTCDateTime() <= ifModifiedSinceDate)
{
struct MHD_Response *response = MHD_create_response_from_data(0, nullptr, MHD_NO, MHD_NO);
struct MHD_Response *response = create_response(0, nullptr, MHD_NO, MHD_NO);
if (response == nullptr)
{
CLog::Log(LOGERROR, "CWebServer[%hu]: failed to create a HTTP 304 response", m_port);
Expand Down Expand Up @@ -728,7 +742,7 @@ int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRe

int CWebServer::CreateRedirect(struct MHD_Connection *connection, const std::string &strURL, struct MHD_Response *&response) const
{
response = MHD_create_response_from_data(0, nullptr, MHD_NO, MHD_NO);
response = create_response(0, nullptr, MHD_NO, MHD_NO);
if (response == nullptr)
{
CLog::Log(LOGERROR, "CWebServer[%hu]: failed to create HTTP redirect response to %s", m_port, strURL.c_str());
Expand Down Expand Up @@ -855,7 +869,7 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
}
else
{
response = MHD_create_response_from_data(0, nullptr, MHD_NO, MHD_NO);
response = create_response(0, nullptr, MHD_NO, MHD_NO);
if (response == nullptr)
{
CLog::Log(LOGERROR, "CWebServer[%hu]: failed to create a HTTP HEAD response for %s", m_port, request.pathUrl.c_str());
Expand Down Expand Up @@ -893,7 +907,7 @@ int CWebServer::CreateErrorResponse(struct MHD_Connection *connection, int respo
}
}

response = MHD_create_response_from_data(payloadSize, payload, MHD_NO, MHD_NO);
response = create_response(payloadSize, payload, MHD_NO, MHD_NO);
if (response == nullptr)
{
CLog::Log(LOGERROR, "CWebServer[%hu]: failed to create a HTTP %d error response", m_port, responseType);
Expand All @@ -905,7 +919,7 @@ int CWebServer::CreateErrorResponse(struct MHD_Connection *connection, int respo

int CWebServer::CreateMemoryDownloadResponse(struct MHD_Connection *connection, const void *data, size_t size, bool free, bool copy, struct MHD_Response *&response) const
{
response = MHD_create_response_from_data(size, const_cast<void*>(data), free ? MHD_YES : MHD_NO, copy ? MHD_YES : MHD_NO);
response = create_response(size, const_cast<void*>(data), free ? MHD_YES : MHD_NO, copy ? MHD_YES : MHD_NO);
if (response == nullptr)
{
CLog::Log(LOGERROR, "CWebServer[%hu]: failed to create a HTTP download response", m_port);
Expand Down