Molybden API
Loading...
Searching...
No Matches
network_delegates.hpp
1// Copyright (c) 2000-2024 TeamDev. All rights reserved.
2// TeamDev PROPRIETARY and CONFIDENTIAL.
3// Use is subject to license terms.
4
5#ifndef MOLYBDEN_NETWORK_DELEGATES_HPP
6#define MOLYBDEN_NETWORK_DELEGATES_HPP
7
8#include <memory>
9#include <vector>
10
11#include "molybden/base/delegate.hpp"
12#include "molybden/base/delegate_action.hpp"
13#include "molybden/cookie/cookie.hpp"
14#include "molybden/network/http_header.hpp"
15#include "molybden/network/url_request.hpp"
16
17namespace molybden {
18
19class Network;
20class UploadData;
21class UrlRequestJob;
22class UrlRequestJobFactory;
23
31 std::shared_ptr<Network> network;
32
37
41 std::shared_ptr<UploadData> upload_data;
42
46 std::vector<HttpHeader> http_headers;
47};
48
53 public:
55 std::unique_ptr<rpc::internal::Callback> callback);
56
60 void override(const std::shared_ptr<UploadData>& upload_data);
61
65 void proceed();
66};
67
75 std::shared_ptr<Network> network;
76
80 std::string url;
81
86};
87
91class CanSetCookieAction : public Action {
92 public:
93 explicit CanSetCookieAction(
94 std::unique_ptr<rpc::internal::Callback> callback);
95
99 void can();
100
104 void cannot();
105};
106
114 std::shared_ptr<Network> network;
115
119 std::string url;
120
124 std::vector<Cookie> cookies;
125};
126
131 public:
132 explicit CanGetCookiesAction(
133 std::unique_ptr<rpc::internal::Callback> callback);
134
138 void can();
139
143 void cannot();
144};
145
153 std::shared_ptr<Network> network;
154
162};
163
168 public:
169 explicit CanAccessFileAction(
170 std::unique_ptr<rpc::internal::Callback> callback);
171
175 void can();
176
180 void cannot();
181};
182
190 std::shared_ptr<Network> network;
191
196
201 std::vector<HttpHeader> http_headers;
202
207 std::string mime_type;
208
213 std::string charset;
214
219 std::string ip_address;
220
225 std::string status_line;
226
231 std::string status_text;
232
238
245};
246
251 public:
252 explicit ReceiveHeadersAction(
253 std::unique_ptr<rpc::internal::Callback> callback);
254
258 void override(const std::vector<HttpHeader>& headers);
259
263 void proceed();
264};
265
273 std::shared_ptr<Network> network;
274
279
284 std::vector<HttpHeader> http_headers;
285};
286
291 public:
293 std::unique_ptr<rpc::internal::Callback> callback);
294
298 void override(const std::vector<HttpHeader>& headers);
299
303 void proceed();
304};
305
313 std::shared_ptr<Network> network;
314
319};
320
325 public:
326 explicit BeforeUrlRequestAction(
327 std::unique_ptr<rpc::internal::Callback> callback);
328
332 void redirect(const std::string& url);
333
337 void cancel();
338
342 void proceed();
343};
344
352 std::shared_ptr<Network> network;
353
358
362 std::shared_ptr<UploadData> upload_data;
363
368 std::vector<HttpHeader> http_headers;
369
373 std::unique_ptr<UrlRequestJobFactory> job_factory;
374};
375
380 public:
382 std::unique_ptr<rpc::internal::Callback> callback);
383
387 void proceed();
388
392 void intercept(std::shared_ptr<UrlRequestJob> url_request_job);
393};
394
550
551} // namespace molybden
552
553#endif // MOLYBDEN_NETWORK_DELEGATES_HPP
The base API that implements classes which represent delegate's action.
Definition delegate_action.hpp:18
The NetworkDelegates::onBeforeSendUploadData action.
Definition network_delegates.hpp:52
void proceed()
Continue with the original upload data.
The NetworkDelegates::onBeforeStartTransaction action arguments.
Definition network_delegates.hpp:290
void proceed()
Continue with the original HTTP headers.
The NetworkDelegates::onBeforeUrlRequest action arguments.
Definition network_delegates.hpp:324
void redirect(const std::string &url)
Redirect the URL request to the given URL.
void proceed()
Continue loading the URL request without redirecting.
void cancel()
Cancel the URL request.
The NetworkDelegates::onCanAccessFile action.
Definition network_delegates.hpp:167
void can()
Allow access to the requested file.
void cannot()
Deny access to the requested file.
The NetworkDelegates::onCanGetCookies action.
Definition network_delegates.hpp:130
void cannot()
Do not send the cookies to a web server.
void can()
Send the cookies to a web server.
Delegates allow you to make decisions that affect the application behavior.
Definition delegate.hpp:30
The NetworkDelegates::onInterceptUrlRequest action arguments.
Definition network_delegates.hpp:379
void intercept(std::shared_ptr< UrlRequestJob > url_request_job)
Intercept the URL request with the given URL request job.
void proceed()
Do not intercept the URL request and proceed normally.
A class that contains all network delegates.
Definition network_delegates.hpp:398
Delegate< CanAccessFileArgs, CanAccessFileAction > onCanAccessFile
Invoked to check if the engine can access a file on the local file system.
Definition network_delegates.hpp:468
Delegate< CanSetCookieArgs, CanSetCookieAction > onCanSetCookie
Invoked to check if the given cookie can be set or not.
Definition network_delegates.hpp:434
Delegate< ReceiveHeadersArgs, ReceiveHeadersAction > onReceiveHeaders
Invoked when the response headers have been received for a URL request.
Definition network_delegates.hpp:488
Delegate< InterceptUrlRequestArgs, InterceptUrlRequestAction > onInterceptUrlRequest
Invoked when a URL request is about to be sent out.
Definition network_delegates.hpp:548
Delegate< CanGetCookiesArgs, CanGetCookiesAction > onCanGetCookies
Invoked to check if the engine can access the given cookie or not.
Definition network_delegates.hpp:451
Delegate< BeforeSendUploadDataArgs, BeforeSendUploadDataAction > onBeforeSendUploadData
Invoked before the upload data is sent to the web server.
Definition network_delegates.hpp:417
Delegate< BeforeUrlRequestArgs, BeforeUrlRequestAction > onBeforeUrlRequest
Invoked when an HTTP request is about to occur.
Definition network_delegates.hpp:526
Delegate< BeforeStartTransactionArgs, BeforeStartTransactionAction > onBeforeStartTransaction
Invoked before the network transaction starts.
Definition network_delegates.hpp:509
The NetworkDelegates::onReceiveHeaders action.
Definition network_delegates.hpp:250
void proceed()
Continue with the original HTTP headers.
The NetworkDelegates::onBeforeSendUploadData action arguments.
Definition network_delegates.hpp:27
std::shared_ptr< UploadData > upload_data
The upload data retrieved from the URL request.
Definition network_delegates.hpp:41
std::shared_ptr< Network > network
The network instance initiated this action.
Definition network_delegates.hpp:31
std::vector< HttpHeader > http_headers
The HTTP headers of the URL request.
Definition network_delegates.hpp:46
UrlRequest url_request
The URL request.
Definition network_delegates.hpp:36
The NetworkDelegates::onBeforeStartTransaction arguments.
Definition network_delegates.hpp:269
std::vector< HttpHeader > http_headers
The list of the HTTP headers of the request or an empty list if the request does not have any HTTP he...
Definition network_delegates.hpp:284
std::shared_ptr< Network > network
The network instance initiated this action.
Definition network_delegates.hpp:273
UrlRequest request
The URL request.
Definition network_delegates.hpp:278
The NetworkDelegates::onBeforeUrlRequest arguments.
Definition network_delegates.hpp:309
UrlRequest request
The URL request.
Definition network_delegates.hpp:318
std::shared_ptr< Network > network
The network instance initiated this action.
Definition network_delegates.hpp:313
The NetworkDelegates::onCanAccessFile action arguments.
Definition network_delegates.hpp:149
std::shared_ptr< Network > network
The network instance initiated this action.
Definition network_delegates.hpp:153
std::string absolute_file_path
Returns the absolute path to the file the request would like to access.
Definition network_delegates.hpp:161
The NetworkDelegates::onCanGetCookie action arguments.
Definition network_delegates.hpp:110
std::vector< Cookie > cookies
A list of cookies that are going to be sent with the URL request.
Definition network_delegates.hpp:124
std::string url
The URL of the request.
Definition network_delegates.hpp:119
std::shared_ptr< Network > network
The network instance initiated this action.
Definition network_delegates.hpp:114
The NetworkDelegates::onInterceptUrlRequest arguments.
Definition network_delegates.hpp:348
std::shared_ptr< Network > network
The network instance initiated this action.
Definition network_delegates.hpp:352
UrlRequest request
The URL request.
Definition network_delegates.hpp:357
std::shared_ptr< UploadData > upload_data
The upload data retrieved from the URL request.
Definition network_delegates.hpp:362
std::unique_ptr< UrlRequestJobFactory > job_factory
The factory for creating UrlRequestJob instances for the url request.
Definition network_delegates.hpp:373
std::vector< HttpHeader > http_headers
The list of the HTTP headers of the request or an empty list if the request does not have any HTTP he...
Definition network_delegates.hpp:368
The NetworkDelegates::onReceiveHeaders action arguments.
Definition network_delegates.hpp:186
std::string charset
Represents the charset data in the lower case retrieved from the Content-Type header.
Definition network_delegates.hpp:213
std::string ip_address
Represents a remote endpoint that was used to make the request.
Definition network_delegates.hpp:219
std::shared_ptr< Network > network
The network instance initiated this action.
Definition network_delegates.hpp:190
uint16_t response_code
Returns the HTTP response code.
Definition network_delegates.hpp:244
UrlRequest request
The URL request.
Definition network_delegates.hpp:195
std::string status_text
Returns a string that represents the short textual description of the response code.
Definition network_delegates.hpp:231
std::vector< HttpHeader > http_headers
The list of the HTTP headers of the request or an empty list if the request does not have any HTTP he...
Definition network_delegates.hpp:201
int64_t content_length
The value of the Content-Length header.
Definition network_delegates.hpp:237
std::string mime_type
The MIME type value initialized with the lower case string retrieved from the Content-Type header.
Definition network_delegates.hpp:207
std::string status_line
Represents the information about HTTP version, response code and the status text.
Definition network_delegates.hpp:225
The details about a URL request.
Definition url_request.hpp:185