mirror of
https://github.com/opus-tango/http-server-in-c.git
synced 2026-03-20 03:55:25 +00:00
add verify if request is get request
This commit is contained in:
@@ -8,8 +8,20 @@ void* client_handler(void* args) {
|
||||
|
||||
ssize_t bytes_read = recv(client, buffer, BUFFER_SIZE, 0);
|
||||
if (bytes_read > 0) {
|
||||
buffer[bytes_read] = '\0';
|
||||
printf("Received: %s\n", buffer);
|
||||
char* ptr = buffer;
|
||||
char* buf_temp[10];
|
||||
char* ptr_temp = buf_temp;
|
||||
while (*ptr != ' ') {
|
||||
*ptr_temp = *ptr;
|
||||
ptr++;
|
||||
ptr_temp++;
|
||||
}
|
||||
*ptr_temp = '\0';
|
||||
if (strcmp(buf_temp, "GET") == 0) {
|
||||
printf("Received a GET request!!\n");
|
||||
} else {
|
||||
printf("Received a non-GET request!!\n");
|
||||
}
|
||||
}
|
||||
free(buffer);
|
||||
return NULL;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef CLIENT_HANDLER_H
|
||||
#define CLIENT_HANDLER_H
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
Reference in New Issue
Block a user