mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-27 15:52:28 +00:00
Support any HTTP method
It's now possible to use redbean Fetch() with arbitrary HTTP methods, e.g. LIST which is used by Hashicorp. There's an eight char limit and uppercase canonicalization still happens. This change also includes a better function for launching a browser tab, that won't deadlock on a headless workstation running Debian. Closes #1107
This commit is contained in:
parent
29eac8e2a2
commit
ad3944a3b6
14 changed files with 249 additions and 412 deletions
|
@ -162,7 +162,7 @@ int _curl(int argc, char *argv[]) {
|
|||
size_t n;
|
||||
char **p;
|
||||
} headers = {0};
|
||||
int method = 0;
|
||||
uint64_t method = 0;
|
||||
int authmode = MBEDTLS_SSL_VERIFY_REQUIRED;
|
||||
int ciphersuite = MBEDTLS_SSL_PRESET_SUITEC;
|
||||
bool includeheaders = false;
|
||||
|
@ -193,7 +193,7 @@ int _curl(int argc, char *argv[]) {
|
|||
postdata = optarg;
|
||||
break;
|
||||
case 'X':
|
||||
if (!(method = GetHttpMethod(optarg, strlen(optarg)))) {
|
||||
if (!(method = ParseHttpMethod(optarg, -1))) {
|
||||
tinyprint(2, prog, ": bad http method: ", optarg, "\n", NULL);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -280,11 +280,13 @@ int _curl(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
char *request = 0;
|
||||
char methodstr[9] = {0};
|
||||
WRITE64LE(methodstr, method);
|
||||
appendf(&request,
|
||||
"%s %s HTTP/1.1\r\n"
|
||||
"Connection: close\r\n"
|
||||
"User-Agent: %s\r\n",
|
||||
kHttpMethod[method], gc(EncodeUrl(&url, 0)), agent);
|
||||
methodstr, gc(EncodeUrl(&url, 0)), agent);
|
||||
|
||||
bool senthost = false;
|
||||
bool sentcontenttype = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue