Squashed merge 3 CLs.

1. "Change CdmResponseType from enum into a struct"
Merged from http://go/wvgerrit/163199
Bug: 253271674

2. "Log request information when server returns 401"
Bug: 260760387
Bug: 186031735
Merged from http://go/wvgerrit/162798

3. "Specify server version on the command line"
Bug: 251599048
Merged from http://go/wvgerrit/158897

Test: build android.hardware.drm-service.widevine
Test: Netflix and Play Movies & TV
Test: build_and_run_all_unit_tests.sh

Bug: 253271674
Change-Id: I70c950acce070609ee0343920ec68e66b058bc23
This commit is contained in:
Robert Shih
2022-11-16 10:02:18 -08:00
committed by Edwin Wong
parent ac9641ae13
commit 096b0eda5a
46 changed files with 1726 additions and 1443 deletions

View File

@@ -6,6 +6,7 @@
#include <errno.h>
#include <gtest/gtest.h>
#include <sstream>
#include "http_socket.h"
@@ -21,6 +22,7 @@ const int kReadBufferSize = 1024;
const int kConnectTimeoutMs = 15000;
const int kWriteTimeoutMs = 12000;
const int kReadTimeoutMs = 12000;
constexpr int kHttpOk = 200;
const std::string kGoogleHeaderUpper("X-Google");
const std::string kGoogleHeaderLower("x-google");
@@ -125,6 +127,17 @@ bool UrlRequest::GetResponse(std::string* message) {
return true;
}
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;
}
// static
int UrlRequest::GetStatusCode(const std::string& response) {
const std::string kHttpVersion("HTTP/1.1 ");