diff options
| author | ame <[email protected]> | 2025-01-13 03:56:06 -0600 |
|---|---|---|
| committer | ame <[email protected]> | 2025-01-13 03:56:06 -0600 |
| commit | 7a11601d5f97c5bcf93eb7d9b534ef39cedb58a8 (patch) | |
| tree | 2f8551fb65b92326ee01ff0016fd34d7629bb959 | |
| parent | 43a0a45291e42f4f9447383794c62a2e8b560ada (diff) | |
select http request type
| -rw-r--r-- | src/net.c | 9 | ||||
| -rw-r--r-- | tests/req.lua | 2 |
2 files changed, 9 insertions, 2 deletions
@@ -156,11 +156,18 @@ int l_srequest(lua_State* L){ lua_pop(L, 1);
}
}
+
+ char* action = "GET";
+ if(params >= check + 1){
+ check++;
+ action = (char*)lua_tostring(L, check);
+ }
+
//char* req = "GET / HTTP/1.1\nHost: amyy.cc\nConnection: Close\n\n";
char* request = calloc(cont_len + header->len + 256, sizeof * request);
- sprintf(request, "GET %s HTTP/1.1\r\nHost: %s\r\nConnection: Close%s\r\n\r\n%s", path, host, header->c, cont);
+ sprintf(request, "%s %s HTTP/1.1\r\nHost: %s\r\nConnection: Close%s\r\n\r\n%s", action, path, host, header->c, cont);
str_free(header);
SSL_write(ssl, request, strlen(request));
diff --git a/tests/req.lua b/tests/req.lua index 3703b26..9eb4cf3 100644 --- a/tests/req.lua +++ b/tests/req.lua @@ -1,6 +1,6 @@ local awa = require "lullaby" -awa.net.srequest("amyy.cc", "/", "meow") +print(awa.net.srequest("amyy.cc", "/", "meow").content) --awa.net.srequest("example.com", "/", "meow") |
