blob: 294ae7f03ea262409c6f0bb1a9447bbdcc1fb824 [file] [log] [blame]
// Copyright (c) 2023 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef QUICHE_BLIND_SIGN_AUTH_BLIND_SIGN_HTTP_INTERFACE_H_
#define QUICHE_BLIND_SIGN_AUTH_BLIND_SIGN_HTTP_INTERFACE_H_
#include <string>
#include "absl/status/statusor.h"
#include "quiche/blind_sign_auth/blind_sign_http_response.h"
#include "quiche/common/platform/api/quiche_export.h"
#include "quiche/common/quiche_callbacks.h"
namespace quiche {
using BlindSignHttpCallback =
quiche::SingleUseCallback<void(absl::StatusOr<BlindSignHttpResponse>)>;
enum class BlindSignHttpRequestType {
kUnknown = 0,
kGetInitialData,
kAuthAndSign,
};
// Interface for async HTTP POST requests in BlindSignAuth.
// Implementers must send a request to a signer server's URL
// and call the provided callback when the request is complete.
class QUICHE_EXPORT BlindSignHttpInterface {
public:
virtual ~BlindSignHttpInterface() = default;
// Non-HTTP errors (like failing to create a socket) must return an
// absl::Status.
// HTTP errors must set status_code and body in BlindSignHttpResponse.
// DoRequest must be a HTTP POST request.
// Requests do not need cookies and must follow redirects.
// The implementer must set Content-Type and Accept headers to
// "application/x-protobuf".
// DoRequest is async. When the request completes, the implementer must call
// the provided callback.
virtual void DoRequest(BlindSignHttpRequestType request_type,
const std::string& authorization_header,
const std::string& body,
BlindSignHttpCallback callback) = 0;
};
} // namespace quiche
#endif // QUICHE_BLIND_SIGN_AUTH_BLIND_SIGN_HTTP_INTERFACE_H_