/[jscoverage]/trunk/tests/http-server-chunked.c
ViewVC logotype

Diff of /trunk/tests/http-server-chunked.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 119 by siliconforks, Sat May 31 21:39:39 2008 UTC revision 120 by siliconforks, Sun Jun 1 14:06:35 2008 UTC
# Line 25  Line 25 
25  #include <unistd.h>  #include <unistd.h>
26    
27  #include "stream.h"  #include "stream.h"
28    #include "util.h"
29    
30  int main(void) {  int main(void) {
31    int s = socket(PF_INET, SOCK_STREAM, 0);    int s = socket(PF_INET, SOCK_STREAM, 0);
# Line 84  Line 85 
85    
86      char * method;      char * method;
87      char * url;      char * url;
88      sscanf(stream->data, "%as %as", &method, &url);      char * request_line = stream->data;
89        char * first_space = strchr(request_line, ' ');
90        assert(first_space != NULL);
91        char * second_space = strchr(first_space + 1, ' ');
92        assert(second_space != NULL);
93        method = xstrndup(stream->data, first_space - request_line);
94        url = xstrndup(first_space + 1, second_space - (first_space + 1));
95    
96      /* send response */      /* send response */
97      char * message;      char * message;
98      if (strcmp(url, "http://127.0.0.1:8000/lower") == 0) {      if (strcmp(url, "http://127.0.0.1:8000/lower") == 0 || strcmp(url, "/lower") == 0) {
99        message = "HTTP/1.1 200 OK\r\n"        message = "HTTP/1.1 200 OK\r\n"
100                  "Connection: close\r\n"                  "Connection: close\r\n"
101                  "Content-type: text/html\r\n"                  "Content-type: text/html\r\n"
# Line 174  Line 181 
181      }      }
182      size_t message_length = strlen(message);      size_t message_length = strlen(message);
183      ssize_t bytes_sent = send(client_socket, message, message_length, 0);      ssize_t bytes_sent = send(client_socket, message, message_length, 0);
184      assert(bytes_sent == message_length);      assert(bytes_sent == (ssize_t) message_length);
185    
186      close(client_socket);      close(client_socket);
187    }    }

Legend:
Removed from v.119  
changed lines
  Added in v.120

  ViewVC Help
Powered by ViewVC 1.1.24