Files
android/libwvdrmengine/cdm/core/test/url_request.h
Alex Dale 3d5bdaeb77 Retry provisioning and license requests on 502 errors
[ Merge of http://go/wvgerrit/219370 ]

Work around the server problem.

Bug: 345333545
Change-Id: Ie1b0021f545c77d61bb2363494239f4fe000f3d5
2025-04-18 12:39:24 -07:00

53 lines
1.4 KiB
C++

// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
#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"
namespace wvcdm {
// Provides simple HTTP request and response service.
// Only POST request method is implemented.
class UrlRequest {
public:
explicit UrlRequest(const std::string& url);
~UrlRequest();
bool is_connected() const { return is_connected_; }
void Reconnect();
bool PostRequest(const std::string& data);
bool PostCertRequestInQueryString(const std::string& data);
bool GetResponse(std::string* message);
static int GetStatusCode(const std::string& response);
// Get the response, and expect the status is OK.
// It will retry if the response code is in the 500 range.
void AssertOkResponseWithRetry(std::string* message);
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);
bool SendRequestOnce();
bool is_connected_;
HttpSocket socket_;
std::string request_;
CORE_DISALLOW_COPY_AND_ASSIGN(UrlRequest);
};
} // namespace wvcdm
#endif // CDM_TEST_URL_REQUEST_H_