aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http
diff options
context:
space:
mode:
authorstanly <stanly@yandex-team.ru>2022-02-10 16:46:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:49 +0300
commit6170310e8721e225f64ddabf7a7358253d7a1249 (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /library/cpp/http
parentcde218e65dfef5ce03a48d641fd8f7913cf17b2d (diff)
downloadydb-6170310e8721e225f64ddabf7a7358253d7a1249.tar.gz
Restoring authorship annotation for <stanly@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/http')
-rw-r--r--library/cpp/http/fetch/httpfetcher.h18
-rw-r--r--library/cpp/http/fetch/httpfsm.rl612
-rw-r--r--library/cpp/http/fetch/httpfsm_ut.cpp12
-rw-r--r--library/cpp/http/fetch/httpheader.h46
-rw-r--r--library/cpp/http/fetch/ya.make2
-rw-r--r--library/cpp/http/misc/ya.make4
-rw-r--r--library/cpp/http/server/options.h10
-rw-r--r--library/cpp/http/server/ya.make4
8 files changed, 54 insertions, 54 deletions
diff --git a/library/cpp/http/fetch/httpfetcher.h b/library/cpp/http/fetch/httpfetcher.h
index 9c439ab60b..7fc251afd2 100644
--- a/library/cpp/http/fetch/httpfetcher.h
+++ b/library/cpp/http/fetch/httpfetcher.h
@@ -35,7 +35,7 @@ public:
static const size_t TCP_MIN = 1500;
static int TerminateNow;
- THttpFetcher()
+ THttpFetcher()
: THttpParser<TCheck>()
, TAlloc()
, TWriter()
@@ -55,15 +55,15 @@ public:
size_t schemelen = strlen(scheme);
if (*path == '/') {
header->base = TStringBuf(scheme, schemelen);
- header->base += TStringBuf("://", 3);
- header->base += TStringBuf(TAgent::pHostBeg, TAgent::pHostEnd - TAgent::pHostBeg);
- header->base += path;
+ header->base += TStringBuf("://", 3);
+ header->base += TStringBuf(TAgent::pHostBeg, TAgent::pHostEnd - TAgent::pHostBeg);
+ header->base += path;
} else {
- if (strlen(path) >= FETCHER_URL_MAX) {
- header->error = HTTP_URL_TOO_LARGE;
- return 0;
- }
- header->base = path;
+ if (strlen(path) >= FETCHER_URL_MAX) {
+ header->error = HTTP_URL_TOO_LARGE;
+ return 0;
+ }
+ header->base = path;
}
if ((ret = TAgent::RequestGet(path, headers, persistent, head_request))) {
diff --git a/library/cpp/http/fetch/httpfsm.rl6 b/library/cpp/http/fetch/httpfsm.rl6
index d3b1425321..eab0328b18 100644
--- a/library/cpp/http/fetch/httpfsm.rl6
+++ b/library/cpp/http/fetch/httpfsm.rl6
@@ -86,10 +86,10 @@ response_status_line = http_version ws+ status_code reason_phrase? eol %set_stat
############ request status line #################
action set_request_uri {
if (request_hd && buflen < FETCHER_URL_MAX) {
- if (!request_hd->request_uri.empty()) {
+ if (!request_hd->request_uri.empty()) {
return -2;
}
- request_hd->request_uri =TStringBuf(buf, buflen);
+ request_hd->request_uri =TStringBuf(buf, buflen);
}
}
action set_http_method {
@@ -225,8 +225,8 @@ mime_type = "text/plain"i %{c(MIME_TEXT)}
| "application/x-bzip2"i | "application/x-rar"i ) %{c(MIME_ARCHIVE)}
| "application/x-dosexec"i %{c(MIME_EXE)}
| "application/x-gzip"i %{c(MIME_GZIP)}
- | "application/json"i %{c(MIME_JSON)}
- | ("application/javascript"i | "text/javascript"i) %{c(MIME_JAVASCRIPT)}
+ | "application/json"i %{c(MIME_JSON)}
+ | ("application/javascript"i | "text/javascript"i) %{c(MIME_JAVASCRIPT)}
| "application/vnd.android.package-archive"i %{c(MIME_APK)}
| ("image/x-icon"i | "image/vnd.microsoft.icon"i) %{c(MIME_IMAGE_ICON)}
;
@@ -253,7 +253,7 @@ action set_location {
buflen --;
}
if (hd && buflen < FETCHER_URL_MAX) {
- hd->location = TStringBuf(buf, buflen);
+ hd->location = TStringBuf(buf, buflen);
}
}
@@ -304,7 +304,7 @@ x_robots_tag = "x-robots-tag"i def >{ AcceptingXRobots = true; } x_robots_value
################# rel_canonical ###############
action set_canonical {
if (hd && buflen < FETCHER_URL_MAX) {
- hd->rel_canonical = TStringBuf(buf, buflen);
+ hd->rel_canonical = TStringBuf(buf, buflen);
}
}
diff --git a/library/cpp/http/fetch/httpfsm_ut.cpp b/library/cpp/http/fetch/httpfsm_ut.cpp
index a581d87773..b018e80101 100644
--- a/library/cpp/http/fetch/httpfsm_ut.cpp
+++ b/library/cpp/http/fetch/httpfsm_ut.cpp
@@ -82,7 +82,7 @@ void THttpHeaderParserTestSuite::TestRequestHeader() {
UNIT_ASSERT_EQUAL(result, 2);
UNIT_ASSERT_EQUAL(httpRequestHeader.http_method, HTTP_METHOD_GET);
UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.host, "www.google.ru:8080"), 0);
- UNIT_ASSERT_EQUAL(httpRequestHeader.request_uri, "/search?q=hi");
+ UNIT_ASSERT_EQUAL(httpRequestHeader.request_uri, "/search?q=hi");
UNIT_ASSERT_EQUAL(httpRequestHeader.GetUrl(), "http://www.google.ru:8080/search?q=hi");
UNIT_ASSERT_EQUAL(httpHeaderParser->lastchar - request + 1,
(i32)strlen(request));
@@ -123,7 +123,7 @@ void THttpHeaderParserTestSuite::TestSplitRequestHeader() {
UNIT_ASSERT_EQUAL(httpRequestHeader.http_method, HTTP_METHOD_GET);
UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.host, "www.google.ru:8080"), 0);
- UNIT_ASSERT_EQUAL(httpRequestHeader.request_uri, "/search?q=hi");
+ UNIT_ASSERT_EQUAL(httpRequestHeader.request_uri, "/search?q=hi");
}
}
@@ -143,7 +143,7 @@ void THttpHeaderParserTestSuite::TestTrailingData() {
UNIT_ASSERT_EQUAL(result, 2);
UNIT_ASSERT_EQUAL(httpRequestHeader.http_method, HTTP_METHOD_GET);
UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.host, "www.google.ru:8080"), 0);
- UNIT_ASSERT_EQUAL(httpRequestHeader.request_uri, "/search?q=hi");
+ UNIT_ASSERT_EQUAL(httpRequestHeader.request_uri, "/search?q=hi");
UNIT_ASSERT_EQUAL(TString(httpHeaderParser->lastchar + 1), "high.ru");
UNIT_ASSERT_EQUAL(httpRequestHeader.http_minor, 1);
UNIT_ASSERT_EQUAL(httpRequestHeader.transfer_chunked, -1);
@@ -178,10 +178,10 @@ void THttpHeaderParserTestSuite::TestProxyRequestHeader() {
UNIT_ASSERT_EQUAL(httpRequestHeader.max_age, 100);
UNIT_ASSERT_VALUES_EQUAL(httpRequestHeader.if_modified_since,
TInstant::ParseIso8601Deprecated("1994-10-29 19:43:31Z").TimeT());
- UNIT_ASSERT_EQUAL(httpRequestHeader.request_uri,
+ UNIT_ASSERT_EQUAL(httpRequestHeader.request_uri,
"http://www.google.ru:8080/search?q=hi");
UNIT_ASSERT(httpRequestHeader.GetUrl() ==
- "http://www.google.ru:8080/search?q=hi");
+ "http://www.google.ru:8080/search?q=hi");
UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.host, ""), 0);
UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.from, "webadmin@yandex.ru"), 0);
UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.user_agent,
@@ -420,7 +420,7 @@ void THttpHeaderParserTestSuite::TestRelCanonical() {
"Link: <http://yandex.ru>; rel = \"canonical\"\r\n\r\n";
i32 result = httpHeaderParser->Execute(headers, strlen(headers));
UNIT_ASSERT_EQUAL(result, 2);
- UNIT_ASSERT_EQUAL(httpHeader.rel_canonical, "http://yandex.ru");
+ UNIT_ASSERT_EQUAL(httpHeader.rel_canonical, "http://yandex.ru");
TestFinish();
}
diff --git a/library/cpp/http/fetch/httpheader.h b/library/cpp/http/fetch/httpheader.h
index b2804c9689..b2810bbd41 100644
--- a/library/cpp/http/fetch/httpheader.h
+++ b/library/cpp/http/fetch/httpheader.h
@@ -1,9 +1,9 @@
#pragma once
-#include "exthttpcodes.h"
-
+#include "exthttpcodes.h"
+
#include <library/cpp/mime/types/mime.h>
-
+
#include <util/system/defaults.h>
#include <util/system/compat.h>
#include <util/generic/string.h>
@@ -24,10 +24,10 @@ extern const i64 DEFAULT_IF_MODIFIED_SINCE; /// == -1
extern const i32 DEFAULT_MAX_AGE; /// == -1
extern const i8 DEFAULT_REQUEST_PRIORITY; /// == -1
extern const i32 DEFAULT_RESPONSE_TIMEOUT; /// == -1
-
+
#define HTTP_PREFIX "http://"
#define MAX_LANGREGION_LEN 4
-#define MAXWORD_LEN 55
+#define MAXWORD_LEN 55
enum HTTP_COMPRESSION {
HTTP_COMPRESSION_UNSET = 0,
@@ -75,7 +75,7 @@ public:
i8 compression_method;
i8 transfer_chunked;
i8 connection_closed;
- TString base;
+ TString base;
public:
void Init() {
@@ -93,7 +93,7 @@ public:
content_range_start = -1;
content_range_end = -1;
content_range_entity_length = -1;
- base.clear();
+ base.clear();
}
void Print() const {
@@ -108,19 +108,19 @@ public:
printf("content_range_start: %" PRIi64 "\n", content_range_start);
printf("content_range_end: %" PRIi64 "\n", content_range_end);
printf("content_range_entity_length: %" PRIi64 "\n", content_range_entity_length);
- printf("base: \"%s\"\n", base.c_str());
+ printf("base: \"%s\"\n", base.c_str());
printf("error: %" PRIi16 "\n", error);
}
int SetBase(const char* path,
const char* hostNamePtr = nullptr,
int hostNameLength = 0) {
- if (*path == '/') {
- base = "http://";
- base += TStringBuf(hostNamePtr, hostNameLength);
- base += path;
+ if (*path == '/') {
+ base = "http://";
+ base += TStringBuf(hostNamePtr, hostNameLength);
+ base += path;
} else {
- base = path;
+ base = path;
}
return error;
}
@@ -134,8 +134,8 @@ public:
i8 squid_error;
i8 x_robots_tag; // deprecated, use x_robots_state instead
i16 http_status;
- TString location;
- TString rel_canonical;
+ TString location;
+ TString rel_canonical;
char hreflangs[HREFLANG_MAX];
i64 retry_after;
TString x_robots_state; // 'xxxxx' format, see `library/html/zoneconf/parsefunc.cpp`
@@ -146,9 +146,9 @@ public:
accept_ranges = -1;
squid_error = 0;
x_robots_tag = 0;
- rel_canonical.clear();
+ rel_canonical.clear();
http_status = -1;
- location.clear();
+ location.clear();
hreflangs[0] = 0;
retry_after = DEFAULT_RETRY_AFTER;
x_robots_state = "xxxxx";
@@ -159,14 +159,14 @@ public:
printf("http_status: %" PRIi16 "\n", http_status);
printf("squid_error: %" PRIi8 "\n", squid_error);
printf("accept_ranges: %" PRIi8 "\n", accept_ranges);
- printf("location: \"%s\"\n", location.c_str());
+ printf("location: \"%s\"\n", location.c_str());
printf("retry_after: %" PRIi64 "\n", retry_after);
}
};
struct THttpRequestHeader: public THttpBaseHeader {
public:
- TString request_uri;
+ TString request_uri;
char host[HOST_MAX];
char from[MAXWORD_LEN];
char user_agent[MAXWORD_LEN];
@@ -186,7 +186,7 @@ public:
}
void Init() {
- request_uri.clear();
+ request_uri.clear();
host[0] = 0;
from[0] = 0;
user_agent[0] = 0;
@@ -204,7 +204,7 @@ public:
void Print() const {
THttpBaseHeader::Print();
- printf("request_uri: \"%s\"\n", request_uri.c_str());
+ printf("request_uri: \"%s\"\n", request_uri.c_str());
printf("host: \"%s\"\n", host);
printf("from: \"%s\"\n", from);
printf("user_agent: \"%s\"\n", user_agent);
@@ -231,9 +231,9 @@ public:
char* GetUrl(char* buffer, size_t size) {
if (host[0] == 0 || !strcmp(host, "")) {
- strlcpy(buffer, request_uri.c_str(), size);
+ strlcpy(buffer, request_uri.c_str(), size);
} else {
- snprintf(buffer, size, "http://%s%s", host, request_uri.c_str());
+ snprintf(buffer, size, "http://%s%s", host, request_uri.c_str());
}
return buffer;
}
diff --git a/library/cpp/http/fetch/ya.make b/library/cpp/http/fetch/ya.make
index f5ed6fbcd7..7737127463 100644
--- a/library/cpp/http/fetch/ya.make
+++ b/library/cpp/http/fetch/ya.make
@@ -35,4 +35,4 @@ SET(RAGEL6_FLAGS -CF1)
END()
-RECURSE_FOR_TESTS(ut)
+RECURSE_FOR_TESTS(ut)
diff --git a/library/cpp/http/misc/ya.make b/library/cpp/http/misc/ya.make
index db4d848571..fceb3cf79c 100644
--- a/library/cpp/http/misc/ya.make
+++ b/library/cpp/http/misc/ya.make
@@ -20,5 +20,5 @@ PEERDIR(
)
END()
-
-RECURSE_FOR_TESTS(ut)
+
+RECURSE_FOR_TESTS(ut)
diff --git a/library/cpp/http/server/options.h b/library/cpp/http/server/options.h
index cfcf9ba330..38eda0e5e7 100644
--- a/library/cpp/http/server/options.h
+++ b/library/cpp/http/server/options.h
@@ -70,11 +70,11 @@ public:
/// Default interface name to bind the server. Used when none of BindAddress are provided.
inline THttpServerOptions& SetHost(const TString& host) noexcept {
- Host = host;
-
- return *this;
- }
-
+ Host = host;
+
+ return *this;
+ }
+
/// Default port to bind the server. Used when none of BindAddress are provided.
inline THttpServerOptions& SetPort(ui16 port) noexcept {
Port = port;
diff --git a/library/cpp/http/server/ya.make b/library/cpp/http/server/ya.make
index da2c664741..bae6f33306 100644
--- a/library/cpp/http/server/ya.make
+++ b/library/cpp/http/server/ya.make
@@ -23,5 +23,5 @@ PEERDIR(
)
END()
-
-RECURSE_FOR_TESTS(ut)
+
+RECURSE_FOR_TESTS(ut)