IWebInterfaceBrowserSchemeHandler.h
3.8 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Engine/Source/Runtime/WebBrowser/Public/IWebBrowserSchemeHandler.h
#pragma once
#include "CoreMinimal.h"
/**
* This is the interface that needs to be implemented to handle a request made via a custom scheme.
* It will be created by implementing an IWebBrowserSchemeHandlerFactory, given to the web browser singleton.
*/
class WEBBROWSERUI_API IWebInterfaceBrowserSchemeHandler
{
public:
/**
* An interface for setting response headers emulating a http implementation.
*/
class IHeaders
{
public:
/**
* Sets the mime type for the response.
* @param MimeType The Mime Type.
*/
virtual void SetMimeType(const TCHAR* MimeType) = 0;
/**
* Sets the status code for the response.
* @param StatusCode The status code.
*/
virtual void SetStatusCode(int32 StatusCode) = 0;
/**
* Sets the content length for the response.
* @param ContentLength The size of the response content in bytes.
*/
virtual void SetContentLength(int32 ContentLength) = 0;
/**
* Sets a redirect url for the response. Other calls will be ignored if this is used.
* @param Url The url to redirect to.
*/
virtual void SetRedirect(const TCHAR* Url) = 0;
/**
* Sets a header for the response.
* @param Key The header key.
* @param Value The header value.
*/
virtual void SetHeader(const TCHAR* Key, const TCHAR* Value) = 0;
};
public:
virtual ~IWebInterfaceBrowserSchemeHandler() {}
/**
* Process an incoming request.
* @param Verb This is the verb used for the request (GET, PUT, POST, etc).
* @param Url This is the full url for the request being made.
* @param OnHeadersReady You must execute this delegate once the response headers are ready to be retrieved with GetResponseHeaders.
* You may execute it during this call to state headers are available now.
* @return You should return true if the request has been accepted and will be processed, otherwise false to cancel this request.
*/
virtual bool ProcessRequest(const FString& Verb, const FString& Url, const FSimpleDelegate& OnHeadersReady) = 0;
/**
* Retrieves the headers for this request.
* @param OutHeaders The interface to use to set headers.
*/
virtual void GetResponseHeaders(IHeaders& OutHeaders) = 0;
/**
* Retrieves the headers for this request.
* @param OutBytes You should copy up to BytesToRead of data to this ptr.
* @param BytesToRead The maximum number of bytes that can be copied to OutBytes.
* @param BytesRead You should set this to the number of bytes that were copied.
* This can be set to zero, to indicate more data is not ready yet, and OnMoreDataReady must then be
* executed when there is.
* @param OnMoreDataReady You should execute this delegate when more data is available to read.
* @return You should return true if more data needs to be read, otherwise false if this is the end of the response data.
*/
virtual bool ReadResponse(uint8* OutBytes, int32 BytesToRead, int32& BytesRead, const FSimpleDelegate& OnMoreDataReady) = 0;
/**
* Called if the request should be canceled.
*/
virtual void Cancel() = 0;
};
/**
* This is the interface that needs to be implemented to instantiate a scheme request handler.
*/
class WEBBROWSERUI_API IWebInterfaceBrowserSchemeHandlerFactory
{
public:
virtual ~IWebInterfaceBrowserSchemeHandlerFactory() {}
/**
* Instantiates an appropriate handler for the given request details.
* @param Verb This is the verb used for the request (GET, PUT, POST, etc).
* @param Url This is the full url for the request being made.
*/
virtual TUniquePtr<IWebInterfaceBrowserSchemeHandler> Create(FString Verb, FString Url) = 0;
};