summaryrefslogtreecommitdiffstats
path: root/library/cpp/http/client/fetch/fetch_request.h
diff options
context:
space:
mode:
authorqrort <[email protected]>2022-11-30 23:47:12 +0300
committerqrort <[email protected]>2022-11-30 23:47:12 +0300
commit22f8ae0e3f5d68b92aecccdf96c1d841a0334311 (patch)
treebffa27765faf54126ad44bcafa89fadecb7a73d7 /library/cpp/http/client/fetch/fetch_request.h
parent332b99e2173f0425444abb759eebcb2fafaa9209 (diff)
validate canons without yatest_common
Diffstat (limited to 'library/cpp/http/client/fetch/fetch_request.h')
-rw-r--r--library/cpp/http/client/fetch/fetch_request.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/library/cpp/http/client/fetch/fetch_request.h b/library/cpp/http/client/fetch/fetch_request.h
new file mode 100644
index 00000000000..169c2940d75
--- /dev/null
+++ b/library/cpp/http/client/fetch/fetch_request.h
@@ -0,0 +1,65 @@
+#pragma once
+
+#include "fetch_result.h"
+
+#include <kernel/langregion/langregion.h>
+
+#include <util/datetime/base.h>
+#include <util/generic/ptr.h>
+
+namespace NHttpFetcher {
+ const TDuration DEFAULT_REQUEST_TIMEOUT = TDuration::Minutes(1);
+ const TDuration DEFAULT_REQUEST_FRESHNESS = TDuration::Seconds(10000);
+
+ class TRequest;
+ using TRequestRef = TIntrusivePtr<TRequest>;
+
+ class TRequest: public TAtomicRefCount<TRequest> {
+ private:
+ TRequest(const TRequest&) = default;
+ TRequest& operator=(const TRequest&) = default;
+ void GenerateSequence();
+
+ public:
+ TRequest(const TString& url = "", TCallBack onFetch = TCallBack());
+ TRequest(const TString& url, bool ignoreRobotsTxt, TDuration timeout,
+ TDuration freshness, TCallBack onFetch = TCallBack());
+ TRequest(const TString& url, TDuration timeout, TDuration freshness, bool ignoreRobots,
+ size_t priority, const TMaybe<TString>& login = TMaybe<TString>(),
+ const TMaybe<TString>& password = TMaybe<TString>(),
+ ELangRegion langRegion = ELR_RU, TCallBack onFetch = TCallBack());
+ void Dump(IOutputStream& out);
+ TRequestRef Clone();
+
+ public:
+ TString Url;
+ TMaybe<TString> UnixSocketPath;
+
+ TInstant Deadline; // [default = 1 min]
+ TDuration RdWrTimeout;
+ TMaybe<TDuration> ConnectTimeout;
+ TDuration Freshness; // [default = 1000 sec]
+ size_t Priority; // lower is more important; range [0, 100], default 40
+
+ TMaybe<TString> Login;
+ TMaybe<TString> Password;
+ TMaybe<TString> OAuthToken;
+ bool IgnoreRobotsTxt; // [default = false]
+ ELangRegion LangRegion; // [default = ELR_RU]
+ TCallBack OnFetch; // for async requests
+ ui64 Sequence; // unique id
+ TMaybe<TString> CustomHost; // Use custom host for "Host" header
+ TMaybe<TString> UserAgent; // custom user agen, [default = YandexNews]
+ TMaybe<TString> AcceptEncoding; // custom accept encoding, [default = "gzip, deflate"]
+ bool OnlyHeaders; // [default = false], if true - no content will be fetched (HEAD request)
+ size_t MaxHeaderSize; // returns 1002 error if exceeded
+ size_t MaxBodySize; // returns 1002 error if exceeded
+ TNeedDataCallback NeedDataCallback; // set this callback if you need to check data while fetching
+ // true - coninue fetching, false - stop
+ TMaybe<TString> Method; // for http exotics like "PUT ", "PATCH ", "DELETE ". if doesn't exist, GET or POST will br used
+ TMaybe<TString> PostData; // if exists - send post request
+ TMaybe<TString> ContentType; // custom content-type for post requests
+ // [default = "application/x-www-form-urlencoded"]
+ TVector<TString> ExtraHeaders; // needed for some servers (to auth, for ex.); don't forget to add "\r\n"!
+ };
+}