Request debug headers and log URL correctly
Merged from https://widevine-internal-review.googlesource.com/165861 We want debug headers to help diagnose b/186031735. I also saw that we were only logging the domain name for some errors instead of the full URL. Bug: 186031735 Test: GtsMediaTestCases Change-Id: I4d469a73e54f86d4d3b5d50bd0030fdb2a36df50
This commit is contained in:
@@ -328,14 +328,13 @@ bool HttpSocket::Connect(int timeout_in_ms) {
|
|||||||
} else {
|
} else {
|
||||||
if (GetError() != ERROR_ASYNC_COMPLETE) {
|
if (GetError() != ERROR_ASYNC_COMPLETE) {
|
||||||
// failed right away.
|
// failed right away.
|
||||||
LOGE("cannot connect to %s, errno = %d", domain_name_.c_str(),
|
LOGE("cannot connect to %s, errno = %d", url().c_str(), GetError());
|
||||||
GetError());
|
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// in progress. block until timeout expired or connection established.
|
// in progress. block until timeout expired or connection established.
|
||||||
if (!Wait(/* for_read */ false, timeout_in_ms)) {
|
if (!Wait(/* for_read */ false, timeout_in_ms)) {
|
||||||
LOGE("cannot connect to %s", domain_name_.c_str());
|
LOGE("cannot connect to %s", url().c_str());
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ class HttpSocket {
|
|||||||
const std::string& domain_name() const { return domain_name_; }
|
const std::string& domain_name() const { return domain_name_; }
|
||||||
int port() const { return atoi(port_.c_str()); }
|
int port() const { return atoi(port_.c_str()); }
|
||||||
const std::string& resource_path() const { return resource_path_; }
|
const std::string& resource_path() const { return resource_path_; }
|
||||||
|
std::string url() const {
|
||||||
|
return scheme_ + "://" + domain_name_ + ":" + port_ + resource_path_;
|
||||||
|
}
|
||||||
|
|
||||||
int ReadAndLogErrors(char* data, int len, int timeout_in_ms);
|
int ReadAndLogErrors(char* data, int len, int timeout_in_ms);
|
||||||
int WriteAndLogErrors(const char* data, int len, int timeout_in_ms);
|
int WriteAndLogErrors(const char* data, int len, int timeout_in_ms);
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ void UrlRequest::Reconnect() {
|
|||||||
is_connected_ = true;
|
is_connected_ = true;
|
||||||
} else {
|
} else {
|
||||||
LOGE("Failed to connect: url = %s, port = %d, attempt = %u",
|
LOGE("Failed to connect: url = %s, port = %d, attempt = %u",
|
||||||
socket_.domain_name().c_str(), socket_.port(), i);
|
socket_.url().c_str(), socket_.port(), i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,9 +121,8 @@ bool UrlRequest::GetResponse(std::string* message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConcatenateChunkedResponse(response, message);
|
ConcatenateChunkedResponse(response, message);
|
||||||
LOGV("HTTP response from %s://%s:%d%s: (%zu): %s", socket_.scheme().c_str(),
|
LOGV("HTTP response from %s: (%zu): %s", socket_.url().c_str(),
|
||||||
socket_.domain_name().c_str(), socket_.port(),
|
message->size(), message->c_str());
|
||||||
socket_.resource_path().c_str(), message->size(), message->c_str());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,11 +130,9 @@ void UrlRequest::AssertOkResponse(std::string* message) {
|
|||||||
ASSERT_TRUE(message);
|
ASSERT_TRUE(message);
|
||||||
ASSERT_TRUE(GetResponse(message));
|
ASSERT_TRUE(GetResponse(message));
|
||||||
const int status_code = GetStatusCode(*message);
|
const int status_code = GetStatusCode(*message);
|
||||||
ASSERT_EQ(kHttpOk, status_code)
|
ASSERT_EQ(kHttpOk, status_code) << "HTTP response from " << socket_.url()
|
||||||
<< "HTTP response from " << socket_.scheme() << "://"
|
<< ": (" << message->size() << ") :\n"
|
||||||
<< socket_.domain_name() << ":" << socket_.port()
|
<< *message;
|
||||||
<< socket_.resource_path() << ": (" << message->size() << ") :\n"
|
|
||||||
<< *message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@@ -204,6 +201,7 @@ bool UrlRequest::PostRequestWithPath(const std::string& path,
|
|||||||
|
|
||||||
request.append("Connection: close\r\n");
|
request.append("Connection: close\r\n");
|
||||||
request.append("User-Agent: Widevine CDM v1.0\r\n");
|
request.append("User-Agent: Widevine CDM v1.0\r\n");
|
||||||
|
request.append("X-Return-Encrypted-Headers: request_and_response\r\n");
|
||||||
|
|
||||||
// buffer to store length of data as a string
|
// buffer to store length of data as a string
|
||||||
char data_size_buffer[32] = {0};
|
char data_size_buffer[32] = {0};
|
||||||
|
|||||||
Reference in New Issue
Block a user