ipfs-chromium
block_http_request.h
1 #ifndef IPFS_BLOCK_HTTP_REQUEST_H_
2 #define IPFS_BLOCK_HTTP_REQUEST_H_
3 
4 #include <ipfs_client/gw/gateway_request.h>
5 
6 #include <ipfs_client/ctx/http_api.h>
7 #include <vocab/raw_ptr.h>
8 
9 namespace network {
10 struct ResourceRequest;
11 class SimpleURLLoader;
12 } // namespace network
13 namespace network::mojom {
14 class URLLoaderFactory;
15 class URLResponseHead;
16 } // namespace network::mojom
17 class GURL;
18 
19 namespace ipfs {
20 
24 class BlockHttpRequest : public std::enable_shared_from_this<BlockHttpRequest> {
25  std::unique_ptr<network::SimpleURLLoader> loader_;
26 
27  public:
28  using HttpCompleteCallback = ctx::HttpApi::OnComplete;
29  BlockHttpRequest(ipfs::HttpRequestDescription, HttpCompleteCallback);
30  ~BlockHttpRequest() noexcept;
31 
33  void Cancel();
34 
35  private:
37  HttpCompleteCallback callback_;
38  std::string status_line_;
39  ctx::HttpApi::Hdrs header_accessor_ = [](auto) {
40  return std::string{};
41  };
42 
43  void OnResponseHead(GURL const&, network::mojom::URLResponseHead const&);
44  void OnResponse(std::shared_ptr<BlockHttpRequest>,
45  std::unique_ptr<std::string> body);
46 };
47 } // namespace ipfs
48 
49 #endif // IPFS_BLOCK_HTTP_REQUEST_H_
Definition: block_http_request.h:24
Definition: http_request_description.h:12