Skip to content

Commit

Permalink
http.c: reply the same proto as in the request
Browse files Browse the repository at this point in the history
  • Loading branch information
mezantrop committed Oct 4, 2023
1 parent 0276aed commit df346e0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

* 2023.10.04 Current
* `http.c`: `http_server_request()` reply the same protocol as in the request

* 2023.09.28 ts-warp-1.3.9, gui-warp-1.0.11 (gui-warp-1.0.17-mac), ns-warp-1.0.7
* `NS-Warp`: rolled-back to stable; fixed many errors; version bump; `README.md` update
* MacOS GUI-WARP app: remove references to CLI configuration
Expand Down
6 changes: 4 additions & 2 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ extern char *pfile_name;

/* ------------------------------------------------------------------------------------------------------------------ */
int http_server_request(int socket, struct uvaddr *daddr) {
char buf[64 * BUF_SIZE_1KB];
char buf[64 * BUF_SIZE_1KB] = {0};

int rcount;
char *method = NULL, *url = NULL, *proto = NULL;
char host[HOST_NAME_MAX] = {0};
Expand Down Expand Up @@ -78,7 +79,8 @@ int http_server_request(int socket, struct uvaddr *daddr) {
else SIN6_PORT(daddr->ip_addr) = port;

/* TODO: Check connection; Reply real status */
if (send(socket, HTTP_PROXY_REPLY_200, sizeof(HTTP_PROXY_REPLY_200) -1, 0) == -1) {
snprintf(buf, sizeof(buf), "%s %s OK\r\nProxy-agent: %s\r\n\r\n", proto, HTTP_RESPONSE_200, PROG_NAME_FULL);
if (send(socket, buf, strlen(buf), 0) == -1) {
printl(LOG_CRIT, "Unable to send reply to the HTTP client");
return 1;
}
Expand Down
2 changes: 0 additions & 2 deletions http.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

#define PROXY_PROTO_HTTP 'H'

#define HTTP_PROXY_REPLY_200 "HTTP/1.1 200 OK\r\nProxy-agent: "PROG_NAME_FULL"\r\n\r\n"

#define HTTP_REQUEST_METHOD_CONNECT "CONNECT"

#define HTTP_REQEST_PROTOCOL "HTTP/1.1"
Expand Down

0 comments on commit df346e0

Please sign in to comment.