Skip to content

Instantly share code, notes, and snippets.

@ampledata
Created March 10, 2011 15:07
Show Gist options
  • Save ampledata/864220 to your computer and use it in GitHub Desktop.
Save ampledata/864220 to your computer and use it in GitHub Desktop.
#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