Compare commits
4 Commits
49030166f3
...
dbbf6bf0c5
Author | SHA1 | Date | |
---|---|---|---|
dbbf6bf0c5 | |||
aed4fdb08a | |||
521cdd7941 | |||
a563ec0e79 |
12
main.c
Normal file
12
main.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "url.h"
|
||||
#include "request.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
char* url_str = "http://www.google.com";
|
||||
// URL* url = new_url(url_str);
|
||||
// printf("Schema is %s\nHostname is %s\nPort is %s\nFilepath is %s\n",get_schema(url),get_hostname(url),get_port(url),get_filepath(url));
|
||||
|
||||
Request* req = new_request(url_str,"GET");
|
||||
printf("%s",make_request(req));
|
||||
}
|
11
request.c
11
request.c
@@ -1,4 +1,5 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "url.h"
|
||||
#include "request.h"
|
||||
@@ -25,18 +26,18 @@ char* make_request(Request* req) {
|
||||
|
||||
strcat(request_str,req->req_type);
|
||||
strcat(request_str," ");
|
||||
strcat(request_str,req->url->filepath);
|
||||
strcat(request_str,get_filepath(req->url));
|
||||
strcat(request_str," HTTP/1.1");
|
||||
strcat(request_str,"\r\n");
|
||||
strcat(request_str,"Host: ");
|
||||
strcat(request_str,req->url->hostname);
|
||||
strcat(request_str,get_hostname(req->url));
|
||||
strcat(request_str,"\r\n\r\n");
|
||||
|
||||
return request_str;
|
||||
|
||||
if (strcmp(get_schema(req->url),"http") == 0) {
|
||||
|
||||
if (strcmp(req->url->schema,"http") == 0) {
|
||||
|
||||
} else if (strcmp(req->url->schema,"https") == 0) {
|
||||
} else if (strcmp(get_schema(req->url),"https") == 0) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,7 @@
|
||||
#include "url.h"
|
||||
|
||||
typedef struct Request_s Request;
|
||||
|
||||
Request* new_request(char* url,char* req_type);
|
||||
URL* get_url(Request* req);
|
||||
char* make_request(Request* req);
|
||||
|
Reference in New Issue
Block a user