Created
March 10, 2011 15:07
-
-
Save ampledata/864220 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <stdio.h> | |
#include "handler.h" | |
void handle_request(int sockfd, const char *request) | |
{ | |
int i; | |
int b; | |
char path[16]; | |
char msg[100]; | |
for (i=0;i<16;i++) { | |
if (request[i] == ' ') { | |
i++; | |
for (b=0;b<16;b++) { | |
if (request[b+i] != ' ') { | |
path[b] = request[b+i]; | |
} else { | |
break; | |
} | |
} | |
break; | |
} | |
} | |
path[b] = '\0'; | |
snprintf(msg, 100, "HTTP 200 OK\r\n\r\nHello %s", path); | |
write(sockfd, msg, strlen(msg)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment