Subversion Repositories Tewi

Rev

Rev 46 | Rev 69 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 46 Rev 64
Line 1... Line 1...
1
/* $Id: http.c 46 2024-09-18 09:58:45Z nishi $ */
1
/* $Id: http.c 64 2024-09-18 20:58:17Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "../config.h"
5
#include "../config.h"
6
 
6
 
Line 30... Line 30...
30
		for(i = 0; req->headers[i] != NULL; i++) free(req->headers[i]);
30
		for(i = 0; req->headers[i] != NULL; i++) free(req->headers[i]);
31
		free(req->headers);
31
		free(req->headers);
32
	}
32
	}
33
	if(req->body != NULL) free(req->body);
33
	if(req->body != NULL) free(req->body);
34
	if(req->version != NULL) free(req->version);
34
	if(req->version != NULL) free(req->version);
-
 
35
 
-
 
36
	req->method = NULL;
-
 
37
	req->path = NULL;
-
 
38
	req->query = NULL;
-
 
39
	req->headers = NULL;
-
 
40
	req->body = NULL;
-
 
41
	req->version = NULL;
35
}
42
}
36
 
43
 
37
int tw_http_parse(SSL* ssl, int sock, struct tw_http_request* req) {
44
int tw_http_parse(SSL* ssl, int sock, struct tw_http_request* req) {
38
	char buffer[512];
45
	char buffer[512];
39
	char cbuf[2];
46
	char cbuf[2];
Line 73... Line 80...
73
			}
80
			}
74
#ifndef NO_SSL
81
#ifndef NO_SSL
75
		}
82
		}
76
#endif
83
#endif
77
		int len = tw_read(ssl, sock, buffer, 512);
84
		int len = tw_read(ssl, sock, buffer, 512);
78
		if(len <= 0) break;
85
		if(len <= 0){
-
 
86
			bad = true;
-
 
87
			break;
-
 
88
		}
79
		int i;
89
		int i;
80
		for(i = 0; i < len; i++) {
90
		for(i = 0; i < len; i++) {
81
			char c = buffer[i];
91
			char c = buffer[i];
82
			if(phase == 0) {
92
			if(phase == 0) {
83
				if(c == ' ') {
93
				if(c == ' ') {