diff --git a/.githooks/commit-msg b/.githooks/commit-msg
new file mode 100755
index 0000000..52e7a30
--- /dev/null
+++ b/.githooks/commit-msg
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+format() {
+ sed -e 's/^fix:/доза:/' \
+ -e '/^# ------------------------ >8 ------------------------$/,$d' \
+ -e '/^#/d'
+}
+
+translated="$(curl -s \
+ http://localhost:9000/translate \
+ -H 'Content-Type: text/html' \
+ --data-binary @- -o- < <(format < "$1") | \
+ tail -n +2 | \
+ perl -pe 's,(.*?),\1,g')"
+
+[ -n "$translated" ] && echo "$translated" > "$1"
diff --git a/.gitignore b/.gitignore
index b50f60d..f364d66 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,4 @@
-.cache/
-/test
build/
-cache/
+.cache/
cmake-build*/
compile_commands.json
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..79d1dc3
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "puppy/include/http"]
+ path = puppy/include/http
+ url = https://github.com/yhirose/cpp-httplib
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..69b2b44
--- /dev/null
+++ b/README.md
@@ -0,0 +1,34 @@
+# promty
+
+## Собирание
+
+Чтобы строить проект, Вы нуждаетесь:
+1. Получить **законную копию** "X-переводчика ПРОМТ Magic Gooddy 6.0.0.205" (да, мы фактически имеем эти DVD),
+2. Установите это на вашей машине "Окна"
+3. Бегите сервером SSH на той машине
+4. Управляемый `puppy/scripts/prepare_environment.sh "WINDOWS_USER@WINDOWS_IP"`. Это будет тянуть все необходимые файлы и ключи регистр
+5. Управляемый `docker compose up -d --build`
+
+## Вклад
+
+### Передайте Стиль
+
+Эти использования проекта, для которых "обычное передает формат", передают сообщения.
+
+```
+напечатайте [возможности]: передайте описание
+
+дополнительное тело
+
+дополнительная нижняя
+```
+
+Мы используем только известный, стандартизированный передают типы как определено спецификацией:
+
+| Напечатать | Описание |
+|------------------------|-----------------------------------------------------------------------------------------------------------|
+| `подвиг` | Добавляет, что новая особенность к codebase |
+| `доза` | Залатать неполадки в codebase |
+| `доктора` | Изменения только для докторов |
+| `тест` | Сменить испытания |
+| `хозяйственная работа` | Изменения, которые непосредственно не затрагивают кодекс, типа ударов версии или обновлений иждивенчества |
diff --git a/caddy/Caddyfile b/caddy/Caddyfile
index 38827b2..3be3842 100644
--- a/caddy/Caddyfile
+++ b/caddy/Caddyfile
@@ -14,6 +14,10 @@ http://ядро.орг, http://*.ядро.орг {
# we don't want to flood the upstream from the same IP
mode bypass
ttl 30m
+
+ timeout {
+ backend 10m
+ }
}
import Caddyfile.yadro proxy:80
@@ -23,13 +27,24 @@ http://ядро.орг, http://*.ядро.орг {
reverse_proxy {
dynamic a puppy 80
lb_policy least_conn
+
+ transport http {
+ response_header_timeout 10m
+ read_timeout 10m
+ write_timeout 10m
+ }
}
cache {
allowed_http_verbs POST
ttl 7d
+
+ key {
+ headers X-Translation-Direction
+ }
+
timeout {
- backend 1m
+ backend 10m
}
}
}
diff --git a/caddy/Caddyfile.yadro b/caddy/Caddyfile.yadro
index c8244f5..c8a7c6d 100644
--- a/caddy/Caddyfile.yadro
+++ b/caddy/Caddyfile.yadro
@@ -75,6 +75,6 @@ handle @surely_static {
redir @known_host https://{kernel}{uri} permanent
}
-# TOOO: cache by path for 30 minutes
+# TODO: cache by path for 30 minutes
reverse_proxy {args[0]}
diff --git a/caddy/Dockerfile b/caddy/Dockerfile
index 3d21c17..a2e47ee 100644
--- a/caddy/Dockerfile
+++ b/caddy/Dockerfile
@@ -1,8 +1,6 @@
FROM caddy:builder AS builder
-
RUN --mount=type=cache,target=/go/pkg/mod xcaddy build \
--with github.com/caddyserver/cache-handler
FROM caddy:latest
-
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
diff --git a/docker-compose.yml b/docker-compose.yml
index 1bb0852..45428e3 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,33 +1,35 @@
services:
puppies:
- networks:
- - promty
+ networks: [promty]
build: puppy
hostname: puppy
- stop_signal: SIGINT
volumes:
- /dev/shm/puppy-temp:/tmpfs
- - ./cache:/cache
deploy:
mode: replicated
- replicas: 1
+ replicas: 3
endpoint_mode: vip
+ update_config:
+ order: start-first
proxy:
- networks:
- - promty
+ networks: [promty]
container_name: proxy
build: proxy
+ depends_on:
+ puppies:
+ condition: service_healthy
caddy:
- networks:
- - promty
+ networks: [promty]
container_name: caddy
build: caddy
volumes:
- ./caddy:/etc/caddy
+ depends_on: [proxy]
ports:
- 80:80
+ - 9000:9000
networks:
promty:
diff --git a/domains b/domains
index 110ffcf..b993a5b 100644
--- a/domains
+++ b/domains
@@ -25,7 +25,7 @@
линукс.ядро.орг linux.kernel.org
саял.ядро.орг lkml.kernel.org
уздечка.ядро.орг lore.kernel.org
-почта.ядро.орг mail.kernel.org
+кольчуга.ядро.орг mail.kernel.org
социальные.сми.ядро.орг media.social.kernel.org
край.зеркал.ядро.орг mirrors.edge.kernel.org
зеркала.ядро.орг mirrors.kernel.org
@@ -33,7 +33,7 @@
уздечка.сппн.ядро.орг nntp.lore.kernel.org
нью-йоркские.зеркала.ядро.орг ny.mirrors.kernel.org
источник.нук.ядро.орг nyc.source.kernel.org
-клавиатура.ядро.орг pad.kernel.org
+прокладка.ядро.орг pad.kernel.org
доктора.париж.ядро.орг parisc.docs.kernel.org
путаница.ядро.орг patchwork.kernel.org
люди.ядро.орг people.kernel.org
@@ -43,13 +43,13 @@
источник.греха.ядро.орг sin.source.kernel.org
пппп.ядро.орг smtp.kernel.org
уздечка.пппп.ядро.орг smtp.lore.kernel.org
-подместо.пппп.ядро.орг smtp.subspace.kernel.org
+подпространство.пппп.ядро.орг smtp.subspace.kernel.org
пппп1.ядро.орг smtp1.kernel.org
пппп2.ядро.орг smtp2.kernel.org
пппп3.ядро.орг smtp3.kernel.org
-социальный.ядро.орг social.kernel.org
+социальное.ядро.орг social.kernel.org
редкие.доктора.ядро.орг sparse.docs.kernel.org
-подместо.ядро.орг subspace.kernel.org
+подпространство.ядро.орг subspace.kernel.org
зеркала.резюме.ядро.орг sv.mirrors.kernel.org
сай.отражает.ядро.орг sy.mirrors.kernel.org
мпук.ядро.орг vger.kernel.org
diff --git a/proxy/Dockerfile b/proxy/Dockerfile
index 52f9945..5e46401 100644
--- a/proxy/Dockerfile
+++ b/proxy/Dockerfile
@@ -1,10 +1,15 @@
FROM golang:1.23-alpine AS builder
+
WORKDIR /build
COPY . .
-RUN --mount=type=cache,target=/go/pkg/mod go build
+
+RUN --mount=type=cache,target=/go/pkg/mod go build;
+
FROM alpine AS runner
+
WORKDIR /app
COPY --from=builder /build/proxy .
+
EXPOSE 80/tcp
CMD ./proxy
diff --git a/proxy/main.go b/proxy/main.go
index 51f9d5a..7d01449 100644
--- a/proxy/main.go
+++ b/proxy/main.go
@@ -23,6 +23,7 @@ func main() {
// We only support gzip decoding
r.Out.Header.Set("Accept-Encoding", "gzip")
+ r.Out.Header.Set("User-Agent", "ядро.орг/1.0")
},
ModifyResponse: func(r *http.Response) error {
// Disable security policy because of the domain restrictions.
@@ -67,7 +68,7 @@ func main() {
return original_raw
}
- return []byte("http://" + yadro + "/") // TODO: https
+ return []byte("https://" + yadro + "/")
})))
}
@@ -87,11 +88,15 @@ func main() {
http.ListenAndServe("0.0.0.0:80", proxy)
}
-func replaceDomains(response []byte) []byte {
+func replaceDomains(response string) string {
re := regexp.MustCompile(`(?i)[A-Za-z\-\.]*\.?kernel\.org`)
+ response = strings.NewReplacer(
+ "%3F", "?",
+ "%26", "&",
+ ).Replace(response)
- response = re.ReplaceAllFunc(response, func(original_raw []byte) []byte {
- kernel := strings.ToLower(string(original_raw))
+ response = re.ReplaceAllStringFunc(response, func(original_raw string) string {
+ kernel := strings.ToLower(original_raw)
// Strip `www.`
kernel = strings.TrimPrefix(kernel, "www.")
@@ -103,42 +108,46 @@ func replaceDomains(response []byte) []byte {
return original_raw
}
- return []byte(yadro)
+ return yadro
})
- response = bytes.ReplaceAll(response, []byte("%3F"), []byte("?"))
- response = bytes.ReplaceAll(response, []byte("%26"), []byte("&"))
- response = bytes.ReplaceAll(response, []byte("https"), []byte("http")) // TODO: TEMP
-
return response
}
-func translateWithPromtPuppies(response []byte) []byte {
+func translateWithPromtPuppies(response string) string {
// Don't try to translate empty body (30x, etc)
if len(response) == 0 {
return response
}
- req, _ := http.NewRequest("POST", "http://caddy:9000/translate", bytes.NewReader(response))
+ req, _ := http.NewRequest("POST", "http://caddy:9000/translate", strings.NewReader(response))
req.Header.Add("Content-Type", "text/html")
resp, err := http.DefaultClient.Do(req)
if err != nil {
- fmt.Fprintln(os.Stderr, "Error in first", err)
- return []byte{0}
+ fmt.Fprintln(os.Stderr, "Error in while translating", err)
+ return ""
}
- response, _ = io.ReadAll(resp.Body)
-
+ var translated strings.Builder
+ io.Copy(&translated, resp.Body)
resp.Body.Close()
- return response
+ return translated.String()
+}
+
+func enfunnify(response string) string {
+ return strings.NewReplacer(
+ "tarball", "tar ball",
+ ).Replace(response)
}
func modifyResponse(response []byte) []byte {
- response = translateWithPromtPuppies(response)
- response = replaceDomains(response)
- return response
+ s := string(response)
+ s = enfunnify(s)
+ s = translateWithPromtPuppies(s)
+ s = replaceDomains(s)
+ return []byte(s)
}
diff --git a/puppy/Dockerfile b/puppy/Dockerfile
index c539092..b235ad9 100644
--- a/puppy/Dockerfile
+++ b/puppy/Dockerfile
@@ -1,41 +1,47 @@
#check=skip=JSONArgsRecommended
-FROM debian:12-slim AS builder
+
+FROM debian:13-slim AS builder
RUN apt-get update && DEBIAN_FRONTEND=noninteracive apt-get install -y \
--no-install-recommends cmake g++-mingw-w64-i686-posix g++ make && \
- apt-get clean && rm -rf /var/lib/apt/lists/*
+ apt-get clean && rm -rf /var/lib/apt/lists/*;
WORKDIR /build
-COPY . .
-RUN g++ -o healthcheck -I./include ./app/healthcheck.cpp
+
+COPY app/healthcheck.cpp app/healthcheck.cpp
+COPY include/http include/http
+RUN g++ -o healthcheck -I./include ./app/healthcheck.cpp;
+
+COPY app app
+COPY include include
+COPY src src
+COPY CMakeLists.txt .
RUN --mount=type=cache,target=cmake-build cmake -B cmake-build \
-DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ && cmake --build cmake-build -j$(nproc) && \
- cp cmake-build/promt-puppy.exe .
+ cp cmake-build/promt-puppy.exe .;
-FROM debian:12-slim AS runner
+
+FROM debian:13-slim AS runner
ENV WINEPREFIX=/wineprefix \
- DEBIAN_FRONTEND=noninteracive
+ XDG_RUNTIME_DIR=/tmp/ \
+ DEBIAN_FRONTEND=noninteracive \
+ WINEDEBUG=-all
+
RUN dpkg --add-architecture i386 && apt-get update && \
apt-get install -y --no-install-recommends \
wine wine64 wine32:i386 && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
- wineboot -i && echo "Sleeping for 15 seconds..." && sleep 15 && \
- mkdir /tmpfs && ln -sf /tmpfs $WINEPREFIX/drive_c/tmpfs
-
+ mkdir -p /tmpfs $WINEPREFIX/drive_c && ln -sf /tmpfs $WINEPREFIX/drive_c/tmpfs;
COPY build/ $WINEPREFIX/drive_c
-RUN wine regedit $WINEPREFIX/drive_c/registry.reg && \
- echo "Sleeping for 15 seconds" && sleep 15
WORKDIR /app
-
COPY --from=builder /build/promt-puppy.exe /build/healthcheck .
-
-HEALTHCHECK CMD ./healthcheck
+HEALTHCHECK --start-period=30s --start-interval=1s CMD ./healthcheck;
EXPOSE 80/tcp
VOLUME /cache
+STOPSIGNAL SIGINT
-ENV WINEDEBUG=-all
-
-CMD exec wine promt-puppy.exe
+COPY docker-entrypoint.sh /entrypoint.sh
+ENTRYPOINT ["/entrypoint.sh"]
diff --git a/puppy/app/healthcheck.cpp b/puppy/app/healthcheck.cpp
index f5e023f..110bc3e 100644
--- a/puppy/app/healthcheck.cpp
+++ b/puppy/app/healthcheck.cpp
@@ -1,4 +1,4 @@
-#include "httplib.hpp"
+#include "http/httplib.h"
int main() {
auto res = httplib::Client("127.0.0.1", 80).Get("/health");
diff --git a/puppy/app/main.cpp b/puppy/app/main.cpp
index 1acb218..13a52b2 100644
--- a/puppy/app/main.cpp
+++ b/puppy/app/main.cpp
@@ -1,18 +1,62 @@
-#include "httplib.hpp"
+#include "http/httplib.h"
+#include
+#include
+#include
#include
#include
+#include
#include
#include
+#include
+#include
#include "PromtCtlDocument.hpp"
#include "PromtFTManager.hpp"
+#define EPOCH_DIFF 116444736000000000LL
+#define TICKS_PER_SEC 10000000LL
+
+static LARGE_INTEGER fake_time;
+
+static NTSTATUS WINAPI HookedNtQuerySystemTime(PLARGE_INTEGER time)
+{
+ if (time)
+ time->QuadPart = fake_time.QuadPart;
+
+ fake_time.QuadPart += TICKS_PER_SEC;
+ return 0;
+}
+
+static void InstallTimeHook()
+{
+ HMODULE ntdll = GetModuleHandleA("ntdll.dll");
+ if (!ntdll)
+ return;
+
+ auto target = (BYTE *)GetProcAddress(ntdll, "NtQuerySystemTime");
+ if (!target)
+ return;
+
+ DWORD old;
+ VirtualProtect(target, 5, PAGE_EXECUTE_READWRITE, &old);
+
+ intptr_t rel = (BYTE *)HookedNtQuerySystemTime - target - 5;
+ target[0] = 0xE9; // jmp rel32
+ *(int32_t *)(target + 1) = (int32_t)rel;
+
+ VirtualProtect(target, 5, old, &old);
+
+ const char *env = std::getenv("FAKETIME");
+ long long unix_ts = env ? std::strtoll(env, nullptr, 10) : 0;
+ fake_time.QuadPart = unix_ts * TICKS_PER_SEC + EPOCH_DIFF;
+}
+
static inline std::string random_filename(int len = 65) {
static const char ASCII_PRINTABLE[] = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
- std::random_device random_device;
- std::mt19937 generator(random_device());
- std::uniform_int_distribution distribution(0, static_cast(strlen(ASCII_PRINTABLE) - 1));
+ static std::random_device random_device;
+ static std::mt19937 generator(random_device());
+ static std::uniform_int_distribution distribution(0, static_cast(strlen(ASCII_PRINTABLE) - 1));
std::string random_string;
random_string.reserve(len);
for (int i = 0; i < len; ++i)
@@ -61,11 +105,20 @@ static inline auto read_file(const std::string &filename) {
size = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, 0, 0);
std::string out;
- out.resize(size);
- WideCharToMultiByte(CP_UTF8, 0, wstr, -1, out.data(), size, 0, 0);
+ out.resize(size - 1);
+ WideCharToMultiByte(CP_UTF8, 0, wstr, -1, out.data(), size - 1, 0, 0);
delete[] wstr;
- return out;
+ std::string out_lf;
+ out_lf.reserve(out.size());
+
+ for (auto c : out) {
+ if (c == '\r')
+ continue;
+ out_lf.push_back(c);
+ }
+
+ return out_lf;
}
class WebServer {
@@ -142,7 +195,8 @@ class WebServer {
public:
WebServer() {
- if (!std::filesystem::exists(TMP_FOLDER)) std::filesystem::create_directory(TMP_FOLDER);
+ if (!std::filesystem::exists(TMP_FOLDER))
+ std::filesystem::create_directory(TMP_FOLDER);
m_svr.Post("/translate", [this](const httplib::Request &req, httplib::Response &res) {
TranslateHandler(req, res);
@@ -159,6 +213,7 @@ class WebServer {
}
void listen(const char *host = "0.0.0.0", unsigned short port = 80) {
+ print("started!");
m_svr.listen(host, port);
}
@@ -169,12 +224,23 @@ class WebServer {
}
};
+static std::function signal_action;
+
+void signal_handler(int signal) {
+ signal_action(signal);
+}
+
int main() {
- print("Starting...");
+ InstallTimeHook();
CoInitializeEx(NULL, COINIT_MULTITHREADED);
CoInitializeSecurity(nullptr, -1, nullptr, nullptr, RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IDENTIFY, nullptr, EOAC_NONE, nullptr);
WebServer ws;
+
+ signal_action = [&](int x) { ws.stop(); };
+ std::signal(SIGTERM, signal_handler);
+ std::signal(SIGINT, signal_handler);
+
ws.listen();
}
diff --git a/puppy/docker-entrypoint.sh b/puppy/docker-entrypoint.sh
new file mode 100755
index 0000000..82cd9b6
--- /dev/null
+++ b/puppy/docker-entrypoint.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+# shellcheck disable=SC2155
+
+echo 'initializing wine...'
+wineboot -i
+
+echo 'copying registy values...'
+wine regedit "$WINEPREFIX"/drive_c/registry.reg
+
+export FAKETIME="$(cat "$WINEPREFIX"/drive_c/build-date)"
+echo "starting with date $(date -d @"$FAKETIME")..."
+exec wine /app/promt-puppy.exe
diff --git a/puppy/include/http b/puppy/include/http
new file mode 160000
index 0000000..adf58bf
--- /dev/null
+++ b/puppy/include/http
@@ -0,0 +1 @@
+Subproject commit adf58bf474fac638160592d6c3f67da4ebc7df20
diff --git a/puppy/include/httplib.hpp b/puppy/include/httplib.hpp
deleted file mode 100644
index cae875c..0000000
--- a/puppy/include/httplib.hpp
+++ /dev/null
@@ -1,10243 +0,0 @@
-//
-// https://github.com/yhirose/cpp-httplib
-// Copyright (c) 2024 Yuji Hirose. All rights reserved.
-// MIT License
-//
-
-#ifndef CPPHTTPLIB_HTTPLIB_H
-#define CPPHTTPLIB_HTTPLIB_H
-
-#define CPPHTTPLIB_VERSION "0.18.1"
-
-/*
- * Configuration
- */
-
-#ifndef CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND
-#define CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND 5
-#endif
-
-#ifndef CPPHTTPLIB_KEEPALIVE_TIMEOUT_CHECK_INTERVAL_USECOND
-#define CPPHTTPLIB_KEEPALIVE_TIMEOUT_CHECK_INTERVAL_USECOND 10000
-#endif
-
-#ifndef CPPHTTPLIB_KEEPALIVE_MAX_COUNT
-#define CPPHTTPLIB_KEEPALIVE_MAX_COUNT 100
-#endif
-
-#ifndef CPPHTTPLIB_CONNECTION_TIMEOUT_SECOND
-#define CPPHTTPLIB_CONNECTION_TIMEOUT_SECOND 300
-#endif
-
-#ifndef CPPHTTPLIB_CONNECTION_TIMEOUT_USECOND
-#define CPPHTTPLIB_CONNECTION_TIMEOUT_USECOND 0
-#endif
-
-#ifndef CPPHTTPLIB_SERVER_READ_TIMEOUT_SECOND
-#define CPPHTTPLIB_SERVER_READ_TIMEOUT_SECOND 5
-#endif
-
-#ifndef CPPHTTPLIB_SERVER_READ_TIMEOUT_USECOND
-#define CPPHTTPLIB_SERVER_READ_TIMEOUT_USECOND 0
-#endif
-
-#ifndef CPPHTTPLIB_SERVER_WRITE_TIMEOUT_SECOND
-#define CPPHTTPLIB_SERVER_WRITE_TIMEOUT_SECOND 5
-#endif
-
-#ifndef CPPHTTPLIB_SERVER_WRITE_TIMEOUT_USECOND
-#define CPPHTTPLIB_SERVER_WRITE_TIMEOUT_USECOND 0
-#endif
-
-#ifndef CPPHTTPLIB_CLIENT_READ_TIMEOUT_SECOND
-#define CPPHTTPLIB_CLIENT_READ_TIMEOUT_SECOND 300
-#endif
-
-#ifndef CPPHTTPLIB_CLIENT_READ_TIMEOUT_USECOND
-#define CPPHTTPLIB_CLIENT_READ_TIMEOUT_USECOND 0
-#endif
-
-#ifndef CPPHTTPLIB_CLIENT_WRITE_TIMEOUT_SECOND
-#define CPPHTTPLIB_CLIENT_WRITE_TIMEOUT_SECOND 5
-#endif
-
-#ifndef CPPHTTPLIB_CLIENT_WRITE_TIMEOUT_USECOND
-#define CPPHTTPLIB_CLIENT_WRITE_TIMEOUT_USECOND 0
-#endif
-
-#ifndef CPPHTTPLIB_IDLE_INTERVAL_SECOND
-#define CPPHTTPLIB_IDLE_INTERVAL_SECOND 0
-#endif
-
-#ifndef CPPHTTPLIB_IDLE_INTERVAL_USECOND
-#ifdef _WIN32
-#define CPPHTTPLIB_IDLE_INTERVAL_USECOND 10000
-#else
-#define CPPHTTPLIB_IDLE_INTERVAL_USECOND 0
-#endif
-#endif
-
-#ifndef CPPHTTPLIB_REQUEST_URI_MAX_LENGTH
-#define CPPHTTPLIB_REQUEST_URI_MAX_LENGTH 8192
-#endif
-
-#ifndef CPPHTTPLIB_HEADER_MAX_LENGTH
-#define CPPHTTPLIB_HEADER_MAX_LENGTH 8192
-#endif
-
-#ifndef CPPHTTPLIB_REDIRECT_MAX_COUNT
-#define CPPHTTPLIB_REDIRECT_MAX_COUNT 20
-#endif
-
-#ifndef CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT
-#define CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT 1024
-#endif
-
-#ifndef CPPHTTPLIB_PAYLOAD_MAX_LENGTH
-#define CPPHTTPLIB_PAYLOAD_MAX_LENGTH ((std::numeric_limits::max)())
-#endif
-
-#ifndef CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH
-#define CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH 8192
-#endif
-
-#ifndef CPPHTTPLIB_RANGE_MAX_COUNT
-#define CPPHTTPLIB_RANGE_MAX_COUNT 1024
-#endif
-
-#ifndef CPPHTTPLIB_TCP_NODELAY
-#define CPPHTTPLIB_TCP_NODELAY false
-#endif
-
-#ifndef CPPHTTPLIB_IPV6_V6ONLY
-#define CPPHTTPLIB_IPV6_V6ONLY false
-#endif
-
-#ifndef CPPHTTPLIB_RECV_BUFSIZ
-#define CPPHTTPLIB_RECV_BUFSIZ size_t(16384u)
-#endif
-
-#ifndef CPPHTTPLIB_COMPRESSION_BUFSIZ
-#define CPPHTTPLIB_COMPRESSION_BUFSIZ size_t(16384u)
-#endif
-
-#ifndef CPPHTTPLIB_THREAD_POOL_COUNT
-#define CPPHTTPLIB_THREAD_POOL_COUNT \
- ((std::max)(8u, std::thread::hardware_concurrency() > 0 \
- ? std::thread::hardware_concurrency() - 1 \
- : 0))
-#endif
-
-#ifndef CPPHTTPLIB_RECV_FLAGS
-#define CPPHTTPLIB_RECV_FLAGS 0
-#endif
-
-#ifndef CPPHTTPLIB_SEND_FLAGS
-#define CPPHTTPLIB_SEND_FLAGS 0
-#endif
-
-#ifndef CPPHTTPLIB_LISTEN_BACKLOG
-#define CPPHTTPLIB_LISTEN_BACKLOG 5
-#endif
-
-/*
- * Headers
- */
-
-#ifdef _WIN32
-#ifndef _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_WARNINGS
-#endif //_CRT_SECURE_NO_WARNINGS
-
-#ifndef _CRT_NONSTDC_NO_DEPRECATE
-#define _CRT_NONSTDC_NO_DEPRECATE
-#endif //_CRT_NONSTDC_NO_DEPRECATE
-
-#if defined(_MSC_VER)
-#if _MSC_VER < 1900
-#error Sorry, Visual Studio versions prior to 2015 are not supported
-#endif
-
-#pragma comment(lib, "ws2_32.lib")
-
-#ifdef _WIN64
-using ssize_t = __int64;
-#else
-using ssize_t = long;
-#endif
-#endif // _MSC_VER
-
-#ifndef S_ISREG
-#define S_ISREG(m) (((m) & S_IFREG) == S_IFREG)
-#endif // S_ISREG
-
-#ifndef S_ISDIR
-#define S_ISDIR(m) (((m) & S_IFDIR) == S_IFDIR)
-#endif // S_ISDIR
-
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif // NOMINMAX
-
-#include
-#include
-#include
-
-#ifndef WSA_FLAG_NO_HANDLE_INHERIT
-#define WSA_FLAG_NO_HANDLE_INHERIT 0x80
-#endif
-
-using socket_t = SOCKET;
-#ifdef CPPHTTPLIB_USE_POLL
-#define poll(fds, nfds, timeout) WSAPoll(fds, nfds, timeout)
-#endif
-
-#else // not _WIN32
-
-#include
-#if !defined(_AIX) && !defined(__MVS__)
-#include
-#endif
-#ifdef __MVS__
-#include
-#ifndef NI_MAXHOST
-#define NI_MAXHOST 1025
-#endif
-#endif
-#include
-#include
-#include
-#ifdef __linux__
-#include
-#endif
-#include
-#ifdef CPPHTTPLIB_USE_POLL
-#include
-#endif
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-using socket_t = int;
-#ifndef INVALID_SOCKET
-#define INVALID_SOCKET (-1)
-#endif
-#endif //_WIN32
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include