Log X-Google fields on failed HTTP requests.

[ Merge of http://go/wvgerrit/103395 ]

To help with debugging failures in HTTP requests during unit tests,
this CL adds logging for Google's debugging response header fields.
These fields are of the type "X-Google-*" or "x-google-*" and provide
information such as the service name, server cell, error details, and
other details that can help isolate the cause of failure on the
server's end.

An additional unittest has been created to test the parser for the
header fields.

Tests that are known to exprience HTTP failures have been extended
to include logs for these fields should they be present.

Bug: 137619348
Test: Linux unit tests and Jenkins test
Change-Id: I69959af2ba91510f345bbb02cf7ca35c3f1119da
This commit is contained in:
Alex Dale
2020-07-28 13:30:42 -07:00
parent df603cbaa1
commit 147c9e0afa
3 changed files with 153 additions and 1 deletions

View File

@@ -5,7 +5,9 @@
#ifndef CDM_TEST_URL_REQUEST_H_
#define CDM_TEST_URL_REQUEST_H_
#include <map>
#include <string>
#include "disallow_copy_and_assign.h"
#include "http_socket.h"
@@ -27,6 +29,10 @@ class UrlRequest {
bool GetResponse(std::string* message);
static int GetStatusCode(const std::string& response);
static bool GetDebugHeaderFields(
const std::string& response,
std::map<std::string, std::string>* header_fields);
private:
bool PostRequestWithPath(const std::string& path, const std::string& data);