mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 08:12:28 +00:00
Add /statusz page to redbean plus other enhancements
redbean improvements: - Explicitly disable corking - Simulate Python regex API for Lua - Send warmup requests in main process on startup - Add Class-A granular IPv4 network classification - Add /statusz page so you can monitor your redbean's health - Fix regressions on OpenBSD/NetBSD caused by recent changes - Plug Authorization header into Lua GetUser and GetPass APIs - Recognize X-Forwarded-{For,Host} from local reverse proxies - Add many additional functions to redbean Lua server page API - Report resource usage of child processes on `/` listing page - Introduce `-a` flag for logging child process resource usage - Introduce `-t MILLIS` flag and `ProgramTimeout(ms)` init API - Introduce `-H "Header: value"` flag and `ProgramHeader(k,v)` API Cosmopolitan Libc improvements: - Make strerror() simpler - Make inet_pton() not depend on sscanf() - Fix OpenExecutable() which broke .data section earlier - Fix stdio in cases where it overflows kernel tty buffer - Fix bugs in crash reporting w/o .com.dbg binary present - Add polyfills for SO_LINGER, SO_RCVTIMEO, and SO_SNDTIMEO - Polyfill TCP_CORK on BSD and XNU using TCP_NOPUSH magnums New netcat clone in examples/nc.c: While testing some of the failure conditions for redbean, I noticed that BusyBox's `nc` command is pretty busted, if you use it as an interactive tool, rather than having it be part of a pipeline. Unfortunately this'll only work on UNIX since Windows doesn't let us poll on stdio and sockets at the same time because I don't think they want tools like this running on their platform. So if you want forbidden fruit, it's here so enjoy it
This commit is contained in:
parent
4effa23528
commit
b107d2709f
163 changed files with 4425 additions and 2104 deletions
141
net/http/http.h
141
net/http/http.h
|
@ -1,6 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_HTTP_HTTP_H_
|
||||
#define COSMOPOLITAN_LIBC_HTTP_HTTP_H_
|
||||
#include "libc/alg/alg.h"
|
||||
#include "libc/time/struct/tm.h"
|
||||
|
||||
#define kHttpGet 1
|
||||
|
@ -21,65 +20,72 @@
|
|||
#define kHttpReport 16
|
||||
#define kHttpUnlock 17
|
||||
|
||||
#define kHttpAccept 0
|
||||
#define kHttpAcceptCharset 1
|
||||
#define kHttpAcceptEncoding 2
|
||||
#define kHttpAcceptLanguage 3
|
||||
#define kHttpAge 4
|
||||
#define kHttpAllow 5
|
||||
#define kHttpAuthorization 6
|
||||
#define kHttpCacheControl 7
|
||||
#define kHttpChunked 8
|
||||
#define kHttpLink 9
|
||||
#define kHttpConnection 10
|
||||
#define kHttpContentBase 11
|
||||
#define kHttpContentEncoding 12
|
||||
#define kHttpContentLanguage 13
|
||||
#define kHttpContentLength 14
|
||||
#define kHttpContentLocation 15
|
||||
#define kHttpContentMd5 16
|
||||
#define kHttpContentRange 17
|
||||
#define kHttpContentType 18
|
||||
#define kHttpDate 19
|
||||
#define kHttpEtag 20
|
||||
#define kHttpExpires 21
|
||||
#define kHttpFrom 22
|
||||
#define kHttpHost 23
|
||||
#define kHttpIfMatch 24
|
||||
#define kHttpIfModifiedSince 25
|
||||
#define kHttpIfNoneMatch 26
|
||||
#define kHttpIfRange 27
|
||||
#define kHttpIfUnmodifiedSince 28
|
||||
#define kHttpKeepAlive 29
|
||||
#define kHttpMaxForwards 30
|
||||
#define kHttpPragma 31
|
||||
#define kHttpProxyAuthenticate 32
|
||||
#define kHttpProxyAuthorization 33
|
||||
#define kHttpProxyConnection 34
|
||||
#define kHttpRange 35
|
||||
#define kHttpReferer 36
|
||||
#define kHttpTransferEncoding 37
|
||||
#define kHttpUpgrade 38
|
||||
#define kHttpUserAgent 39
|
||||
#define kHttpVia 40
|
||||
#define kHttpLocation 41
|
||||
#define kHttpPublic 42
|
||||
#define kHttpRetryAfter 43
|
||||
#define kHttpServer 44
|
||||
#define kHttpVary 45
|
||||
#define kHttpWarning 46
|
||||
#define kHttpWwwAuthenticate 47
|
||||
#define kHttpLastModified 48
|
||||
#define kHttpTrailer 49
|
||||
#define kHttpTe 50
|
||||
#define kHttpDnt 51
|
||||
#define kHttpExpect 52
|
||||
#define kHttpContentDisposition 53
|
||||
#define kHttpContentDescription 54
|
||||
#define kHttpOrigin 55
|
||||
#define kHttpUpgradeInsecureRequests 56
|
||||
#define kHttpUri 57
|
||||
#define kHttpHeadersMax 58
|
||||
#define kHttpAccept 0
|
||||
#define kHttpAcceptCharset 1
|
||||
#define kHttpAcceptEncoding 2
|
||||
#define kHttpAcceptLanguage 3
|
||||
#define kHttpAge 4
|
||||
#define kHttpAllow 5
|
||||
#define kHttpAuthorization 6
|
||||
#define kHttpCacheControl 7
|
||||
#define kHttpChunked 8
|
||||
#define kHttpLink 9
|
||||
#define kHttpConnection 10
|
||||
#define kHttpContentBase 11
|
||||
#define kHttpContentEncoding 12
|
||||
#define kHttpContentLanguage 13
|
||||
#define kHttpContentLength 14
|
||||
#define kHttpContentLocation 15
|
||||
#define kHttpContentMd5 16
|
||||
#define kHttpContentRange 17
|
||||
#define kHttpContentType 18
|
||||
#define kHttpDate 19
|
||||
#define kHttpEtag 20
|
||||
#define kHttpExpires 21
|
||||
#define kHttpFrom 22
|
||||
#define kHttpHost 23
|
||||
#define kHttpIfMatch 24
|
||||
#define kHttpIfModifiedSince 25
|
||||
#define kHttpIfNoneMatch 26
|
||||
#define kHttpIfRange 27
|
||||
#define kHttpIfUnmodifiedSince 28
|
||||
#define kHttpKeepAlive 29
|
||||
#define kHttpMaxForwards 30
|
||||
#define kHttpPragma 31
|
||||
#define kHttpProxyAuthenticate 32
|
||||
#define kHttpProxyAuthorization 33
|
||||
#define kHttpProxyConnection 34
|
||||
#define kHttpRange 35
|
||||
#define kHttpReferer 36
|
||||
#define kHttpTransferEncoding 37
|
||||
#define kHttpUpgrade 38
|
||||
#define kHttpUserAgent 39
|
||||
#define kHttpVia 40
|
||||
#define kHttpLocation 41
|
||||
#define kHttpPublic 42
|
||||
#define kHttpRetryAfter 43
|
||||
#define kHttpServer 44
|
||||
#define kHttpVary 45
|
||||
#define kHttpWarning 46
|
||||
#define kHttpWwwAuthenticate 47
|
||||
#define kHttpLastModified 48
|
||||
#define kHttpTrailer 49
|
||||
#define kHttpTe 50
|
||||
#define kHttpDnt 51
|
||||
#define kHttpExpect 52
|
||||
#define kHttpContentDisposition 53
|
||||
#define kHttpContentDescription 54
|
||||
#define kHttpOrigin 55
|
||||
#define kHttpUpgradeInsecureRequests 56
|
||||
#define kHttpUri 57
|
||||
#define kHttpXCsrfToken 58
|
||||
#define kHttpXForwardedFor 59
|
||||
#define kHttpXForwardedHost 60
|
||||
#define kHttpXForwardedProto 61
|
||||
#define kHttpXRequestedWith 62
|
||||
#define kHttpAccessControlRequestMethod 63
|
||||
#define kHttpAccessControlRequestHeaders 64
|
||||
#define kHttpHeadersMax 65
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
@ -111,30 +117,25 @@ extern const char kHttpToken[256];
|
|||
extern const char kHttpMethod[18][8];
|
||||
extern const bool kHttpRepeatable[kHttpHeadersMax];
|
||||
|
||||
const char *GetHttpReason(int);
|
||||
const char *GetHttpHeaderName(int);
|
||||
int GetHttpHeader(const char *, size_t);
|
||||
int GetHttpMethod(const char *, size_t);
|
||||
void InitHttpRequest(struct HttpRequest *);
|
||||
void DestroyHttpRequest(struct HttpRequest *);
|
||||
int ParseHttpRequest(struct HttpRequest *, const char *, size_t);
|
||||
bool HeaderHasSubstring(struct HttpRequest *, const char *, int, const char *,
|
||||
size_t);
|
||||
int NegotiateHttpRequest(int, const char *, uint32_t *, char *, uint32_t *,
|
||||
uint32_t *, bool, long double);
|
||||
bool HeaderHas(struct HttpRequest *, const char *, int, const char *, size_t);
|
||||
int64_t ParseContentLength(const char *, size_t);
|
||||
char *FormatHttpDateTime(char[hasatleast 30], struct tm *);
|
||||
bool ParseHttpRange(const char *, size_t, long, long *, long *);
|
||||
int64_t ParseHttpDateTime(const char *, size_t);
|
||||
const char *GetHttpReason(int);
|
||||
const char *GetHttpHeaderName(int);
|
||||
char *DecodeLatin1(const char *, size_t, size_t *);
|
||||
bool IsValidHttpToken(const char *, size_t);
|
||||
char *EncodeHttpHeaderValue(const char *, size_t, size_t *);
|
||||
char *VisualizeControlCodes(const char *, size_t, size_t *);
|
||||
char *IndentLines(const char *, size_t, size_t *, size_t);
|
||||
bool IsAcceptablePath(const char *, size_t);
|
||||
bool IsAcceptableHost(const char *, size_t);
|
||||
bool IsAcceptablePort(const char *, size_t);
|
||||
bool IsReasonablePath(const char *, size_t);
|
||||
int64_t ParseIp(const char *, size_t);
|
||||
int ParseForwarded(const char *, size_t, uint32_t *, uint16_t *);
|
||||
bool IsMimeType(const char *, size_t, const char *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue