Introduce provider-neutral HTTP contracts and public-client authorization-code orchestration with PKCE S256, strict HTTPS and loopback validation, constant-time state checks, secure OpenSSL entropy, and single-send token exchange semantics. Add independent protocol and adversarial suites covering RFC 7636, RFC3986 encoding, callback failures, response redaction, and no-retry behavior. Concrete networking, browser/listener, token parsing, Secret Service, and Graph integration remain separate follow-up slices.
44 lines
925 B
C++
44 lines
925 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace nocal::sync {
|
|
|
|
enum class HttpMethod { get, post, put, patch, delete_ };
|
|
|
|
struct HttpHeader {
|
|
std::string name;
|
|
std::string value;
|
|
|
|
bool operator==(const HttpHeader&) const = default;
|
|
};
|
|
|
|
struct HttpRequest {
|
|
HttpMethod method{HttpMethod::get};
|
|
std::string url;
|
|
std::vector<HttpHeader> headers;
|
|
std::string body;
|
|
|
|
bool operator==(const HttpRequest&) const = default;
|
|
};
|
|
|
|
struct HttpResponse {
|
|
int status{0};
|
|
std::vector<HttpHeader> headers;
|
|
std::string body;
|
|
|
|
bool operator==(const HttpResponse&) const = default;
|
|
};
|
|
|
|
class HttpTransport {
|
|
public:
|
|
virtual ~HttpTransport() = default;
|
|
|
|
// Performs exactly one request. Retry policy belongs to the caller because
|
|
// only the caller knows whether replay is safe.
|
|
virtual HttpResponse send(const HttpRequest& request) = 0;
|
|
};
|
|
|
|
} // namespace nocal::sync
|