(This is a merge of http://go/wvgerrit/13400 from the Widevine CDM repository.) Replace "}; // namespace" with "} // namespace": ag -l --ignore-dir third_party "}; //" | \ while read f; do sed -r -i 's/\}; \/\//} \/\//' $f ; done Replace "// unnamed namespace" with "// namespace": ag -l --ignore-dir third_party "unnamed namespace" | \ while read f; do sed -r -i 's/unnamed namespace/namespace/' $f ; done Change-Id: I50ece9a127ce669f15cd532dfae1dd741338a075
57 lines
1.4 KiB
C++
57 lines
1.4 KiB
C++
// Copyright 2013 Google Inc. All Rights Reserved.
|
|
|
|
#ifndef CDM_TEST_HTTP_SOCKET_H_
|
|
#define CDM_TEST_HTTP_SOCKET_H_
|
|
|
|
#include <string>
|
|
|
|
#include <gtest/gtest_prod.h>
|
|
#include <openssl/ssl.h>
|
|
|
|
#include "wv_cdm_types.h" // CORE_DISALLOW_COPY_AND_ASSIGN
|
|
|
|
namespace wvcdm {
|
|
|
|
// Provides basic Linux based TCP socket interface.
|
|
class HttpSocket {
|
|
public:
|
|
// A scheme (http:// or https://) is required for the URL.
|
|
explicit HttpSocket(const std::string& url);
|
|
~HttpSocket();
|
|
|
|
bool Connect(int timeout_in_ms);
|
|
void CloseSocket();
|
|
|
|
const std::string& scheme() const { return scheme_; }
|
|
bool secure_connect() const { return secure_connect_; }
|
|
const std::string& domain_name() const { return domain_name_; }
|
|
int port() const { return port_; }
|
|
const std::string& resource_path() const { return resource_path_; }
|
|
|
|
int Read(char* data, int len, int timeout_in_ms);
|
|
int Write(const char* data, int len, int timeout_in_ms);
|
|
|
|
private:
|
|
static bool ParseUrl(const std::string& url, std::string* scheme,
|
|
bool* secure_connect, std::string* domain_name,
|
|
int* port, std::string* path);
|
|
FRIEND_TEST(HttpSocketTest, ParseUrlTest);
|
|
|
|
std::string scheme_;
|
|
bool secure_connect_;
|
|
std::string domain_name_;
|
|
int port_;
|
|
std::string resource_path_;
|
|
bool valid_url_;
|
|
|
|
int socket_fd_;
|
|
SSL* ssl_;
|
|
SSL_CTX* ssl_ctx_;
|
|
|
|
CORE_DISALLOW_COPY_AND_ASSIGN(HttpSocket);
|
|
};
|
|
|
|
} // namespace wvcdm
|
|
|
|
#endif // CDM_TEST_HTTP_SOCKET_H_
|