fix stuff

git-svn-id: file:///raid/svn-personal/tewi/trunk@64 8739d7e6-ffea-ec47-b151-bdff447c6205
This commit is contained in:
Nishi 2024-09-18 20:58:17 +00:00
parent 54108c74b9
commit 13eb135280
2 changed files with 25 additions and 13 deletions

View File

@ -32,6 +32,13 @@ void tw_free_request(struct tw_http_request* req) {
} }
if(req->body != NULL) free(req->body); if(req->body != NULL) free(req->body);
if(req->version != NULL) free(req->version); if(req->version != NULL) free(req->version);
req->method = NULL;
req->path = NULL;
req->query = NULL;
req->headers = NULL;
req->body = NULL;
req->version = NULL;
} }
int tw_http_parse(SSL* ssl, int sock, struct tw_http_request* req) { int tw_http_parse(SSL* ssl, int sock, struct tw_http_request* req) {
@ -75,7 +82,10 @@ int tw_http_parse(SSL* ssl, int sock, struct tw_http_request* req) {
} }
#endif #endif
int len = tw_read(ssl, sock, buffer, 512); int len = tw_read(ssl, sock, buffer, 512);
if(len <= 0) break; if(len <= 0){
bad = true;
break;
}
int i; int i;
for(i = 0; i < len; i++) { for(i = 0; i < len; i++) {
char c = buffer[i]; char c = buffer[i];

View File

@ -428,6 +428,7 @@ void tw_server_pass(int sock, bool ssl, int port, SOCKADDR addr) {
char* vhost = cm_strdup(config.hostname); char* vhost = cm_strdup(config.hostname);
int i; int i;
time_t cmtime = 0; time_t cmtime = 0;
if(req.headers != NULL){
for(i = 0; req.headers[i] != NULL; i += 2) { for(i = 0; req.headers[i] != NULL; i += 2) {
if(cm_strcaseequ(req.headers[i], "Host")) { if(cm_strcaseequ(req.headers[i], "Host")) {
free(vhost); free(vhost);
@ -445,6 +446,7 @@ void tw_server_pass(int sock, bool ssl, int port, SOCKADDR addr) {
#endif #endif
} }
} }
}
cm_log("Server", "Host is %s", vhost); cm_log("Server", "Host is %s", vhost);
int port = s == NULL ? 80 : 443; int port = s == NULL ? 80 : 443;
char* host = cm_strdup(vhost); char* host = cm_strdup(vhost);