aboutsummaryrefslogtreecommitdiff
path: root/zenserver/testing/httptest.h
blob: 2f3482abc5debe79a7777820604c16f27d659610 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include <zenhttp/httpserver.h>

#include <spdlog/spdlog.h>

namespace zen {

/**
 * Test service to facilitate testing the HTTP framework and client interactions
 */
class HttpTestingService : public HttpService
{
public:
	HttpTestingService();
	~HttpTestingService();

	virtual const char*				 BaseUri() const override;
	virtual void					 HandleRequest(HttpServerRequest& Request) override;
	virtual Ref<IHttpPackageHandler> HandlePackageRequest(HttpServerRequest& HttpServiceRequest) override;

	class PackageHandler : public IHttpPackageHandler
	{
	public:
		PackageHandler(const HttpServerRequest& Request);
		~PackageHandler();

		void	 FilterOffer(std::vector<IoHash>& OfferCids) override;
		void	 OnBeginChunks() override;
		IoBuffer CreateTarget(const IoHash& Cid, uint64_t StorageSize) override;
		void	 OnEndChunks() override;
	};

private:
	HttpRequestRouter m_Router;
};

}  // namespace zen