Started working on request constructor

master
Aadhavan Srinivasan 2 years ago
parent deaea2ebdc
commit d0d1660367

@ -1,16 +1,42 @@
#include "stdlib.h" #include <stdlib.h>
#include "url.h" #include "url.h"
#include "request.h" #include "request.h"
#define MAX_BUFFER_SIZE 50000
struct Request_s { struct Request_s {
URL* url; URL* url;
char* req_type; char* req_type;
}; };
Request* new_Request(char* url_str,char* req_type_str) { Request* new_request(char* url_str,char* req_type_str) {
Request* req = malloc(sizeof(struct Request_s)); Request* req = malloc(sizeof(struct Request_s));
req->url = new_url(url_str); req->url = new_url(url_str);
req->req_type = req_type_str; req->req_type = req_type_str;
} }
URL* get_url(Request* req) {
return req->url;
}
char* make_request(Request* req) {
char* request_str = malloc(sizeof(char) * MAX_BUFFER_SIZE);
strcat(request_str,req->req_type);
strcat(request_str," ");
strcat(request_str,req->url->filepath);
strcat(request_str," HTTP/1.1");
strcat(request_str,"\r\n");
strcat(request_str,"Host: ");
strcat(request_str,req->url->hostname);
strcat(request_str,"\r\n\r\n");
if (strcmp(req->url->schema,"http") == 0) {
} else if (strcmp(req->url->schema,"https") == 0) {
}
}

Loading…
Cancel
Save