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

[kinetic] Close sockets when server responds with HTTP/1.0 #1284

Merged
merged 3 commits into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clients/roscpp/src/libros/xmlrpc_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ void XMLRPCManager::releaseXMLRPCClient(XmlRpcClient *c)
{
if (c == i->client_)
{
if (shutting_down_)
if (shutting_down_ || !c->getKeepOpen())
{
// if we are shutting down we won't be re-using the client
i->client_->close();
Expand Down
13 changes: 12 additions & 1 deletion utilities/xmlrpcpp/src/XmlRpcClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ XmlRpcClient::execute(const char* method, XmlRpcValue const& params, XmlRpcValue
return false;

XmlRpcUtil::log(1, "XmlRpcClient::execute: method %s completed.", method);
_header = "";
_response = "";
return true;
}
Expand Down Expand Up @@ -403,7 +404,6 @@ XmlRpcClient::readHeader()

// Otherwise copy non-header data to response buffer and set state to read response.
_response = bp;
_header = ""; // should parse out any interesting bits from the header (connection, etc)...
_connectionState = READ_RESPONSE;
return true; // Continue monitoring this source
}
Expand Down Expand Up @@ -447,6 +447,7 @@ XmlRpcClient::parseResponse(XmlRpcValue& result)
int offset = 0;
if ( ! XmlRpcUtil::findTag(METHODRESPONSE_TAG,_response,&offset)) {
XmlRpcUtil::error("Error in XmlRpcClient::parseResponse: Invalid response - no methodResponse. Response:\n%s", _response.c_str());
_header = "";
return false;
}

Expand All @@ -458,15 +459,25 @@ XmlRpcClient::parseResponse(XmlRpcValue& result)
if ( ! result.fromXml(_response, &offset)) {
XmlRpcUtil::error("Error in XmlRpcClient::parseResponse: Invalid response value. Response:\n%s", _response.c_str());
_response = "";
_header = "";
return false;
}
} else {
XmlRpcUtil::error("Error in XmlRpcClient::parseResponse: Invalid response - no param or fault tag. Response:\n%s", _response.c_str());
_response = "";
_header = "";
return false;
}

_response = "";

// Close connection if protocol is HTTP/1.0
if (_header.rfind("HTTP/1.0", 0) == 0) {
dirk-thomas marked this conversation as resolved.
Show resolved Hide resolved
setKeepOpen(false);
close();
}

_header = "";
return result.valid();
}