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 {
|
||||
if (GetError() != ERROR_ASYNC_COMPLETE) {
|
||||
// failed right away.
|
||||
LOGE("cannot connect to %s, errno = %d", domain_name_.c_str(),
|
||||
GetError());
|
||||
LOGE("cannot connect to %s, errno = %d", url().c_str(), GetError());
|
||||
CloseSocket();
|
||||
return false;
|
||||
} else {
|
||||
// in progress. block until timeout expired or connection established.
|
||||
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();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ class HttpSocket {
|
||||
const std::string& domain_name() const { return domain_name_; }
|
||||
int port() const { return atoi(port_.c_str()); }
|
||||
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 WriteAndLogErrors(const char* data, int len, int timeout_in_ms);
|
||||
|
||||
@@ -94,7 +94,7 @@ void UrlRequest::Reconnect() {
|
||||
is_connected_ = true;
|
||||
} else {
|
||||
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);
|
||||
LOGV("HTTP response from %s://%s:%d%s: (%zu): %s", socket_.scheme().c_str(),
|
||||
socket_.domain_name().c_str(), socket_.port(),
|
||||
socket_.resource_path().c_str(), message->size(), message->c_str());
|
||||
LOGV("HTTP response from %s: (%zu): %s", socket_.url().c_str(),
|
||||
message->size(), message->c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -131,11 +130,9 @@ void UrlRequest::AssertOkResponse(std::string* message) {
|
||||
ASSERT_TRUE(message);
|
||||
ASSERT_TRUE(GetResponse(message));
|
||||
const int status_code = GetStatusCode(*message);
|
||||
ASSERT_EQ(kHttpOk, status_code)
|
||||
<< "HTTP response from " << socket_.scheme() << "://"
|
||||
<< socket_.domain_name() << ":" << socket_.port()
|
||||
<< socket_.resource_path() << ": (" << message->size() << ") :\n"
|
||||
<< *message;
|
||||
ASSERT_EQ(kHttpOk, status_code) << "HTTP response from " << socket_.url()
|
||||
<< ": (" << message->size() << ") :\n"
|
||||
<< *message;
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -204,6 +201,7 @@ bool UrlRequest::PostRequestWithPath(const std::string& path,
|
||||
|
||||
request.append("Connection: close\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
|
||||
char data_size_buffer[32] = {0};
|
||||
|
||||
Reference in New Issue
Block a user