/[jscoverage]/trunk/tests/http-server-empty-header-value.c
ViewVC logotype

Diff of /trunk/tests/http-server-empty-header-value.c

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

revision 505 by siliconforks, Sat Jan 2 04:55:54 2010 UTC revision 570 by siliconforks, Mon May 24 03:13:28 2010 UTC
# Line 55  Line 55 
55      assert(client_socket > 0);      assert(client_socket > 0);
56    
57      /* read request */      /* read request */
58        bool ping = false;
59        bool first = true;
60      int state = 0;      int state = 0;
61      while (state != 2) {      while (state != 2) {
62        uint8_t buffer[8192];        uint8_t buffer[8192];
63        ssize_t bytes_read = recv(client_socket, buffer, 8192, 0);        ssize_t bytes_read = recv(client_socket, buffer, 8192, 0);
64        assert(bytes_read > 0);        assert(bytes_read > 0);
65          if (first) {
66            if (strncmp("GET /ping", buffer, 9) == 0) {
67              ping = true;
68            }
69            first = false;
70          }
71        for (int i = 0; i < bytes_read && state != 2; i++) {        for (int i = 0; i < bytes_read && state != 2; i++) {
72          uint8_t byte = buffer[i];          uint8_t byte = buffer[i];
73          switch (state) {          switch (state) {
# Line 85  Line 93 
93        }        }
94      }      }
95    
96      /* send response */      char * message;
97      char * message = "HTTP/1.1 200 OK\r\nContent-Encoding: \r\nConnection: close\r\nContent-type: text/html\r\n\r\nHello\n";      if (ping) {
98          /* send normal response */
99          message = "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-type: text/html\r\n\r\nHello\n";
100        }
101        else {
102          /* send bogus response */
103          message = "HTTP/1.1 200 OK\r\nContent-Encoding: \r\nConnection: close\r\nContent-type: text/html\r\n\r\nHello\n";
104        }
105      size_t message_length = strlen(message);      size_t message_length = strlen(message);
106      ssize_t bytes_sent = send(client_socket, message, message_length, 0);      ssize_t bytes_sent = send(client_socket, message, message_length, 0);
107      assert(bytes_sent == (ssize_t) message_length);      assert(bytes_sent == (ssize_t) message_length);

Legend:
Removed from v.505  
changed lines
  Added in v.570

  ViewVC Help
Powered by ViewVC 1.1.24