summaryrefslogtreecommitdiffstats
path: root/src/common/networking.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/networking.h')
-rw-r--r--src/common/networking.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/common/networking.h b/src/common/networking.h
new file mode 100644
index 0000000..2554e22
--- /dev/null
+++ b/src/common/networking.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#include "common/thread.h"
+#include "common/FFstrbuf.h"
+
+#ifdef _WIN32
+ #include <minwindef.h>
+#endif
+
+struct addrinfo;
+
+typedef struct FFNetworkingState {
+#ifdef _WIN32
+ uintptr_t sockfd;
+ OVERLAPPED overlapped;
+#else
+ int sockfd;
+ struct addrinfo* addr;
+
+ #ifdef FF_HAVE_THREADS
+ FFThreadType thread;
+ #endif
+#endif
+
+ FFstrbuf command;
+ uint32_t timeout;
+ bool ipv6;
+ bool compression; // if true, HTTP content compression will be enabled if supported
+ bool tfo; // if true, TCP Fast Open will be attempted first, and fallback to traditional connection if it fails
+} FFNetworkingState;
+
+const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, const char* path, const char* headers);
+const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buffer);
+
+#ifdef FF_HAVE_ZLIB
+const char* ffNetworkingLoadZlibLibrary(void);
+bool ffNetworkingDecompressGzip(FFstrbuf* buffer, char* headerEnd);
+#endif