/[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 609 by siliconforks, Sat Jan 2 04:55:54 2010 UTC revision 610 by siliconforks, Fri Sep 24 20:35:36 2010 UTC
# Line 26  Line 26 
26  #include "stream.h"  #include "stream.h"
27  #include "util.h"  #include "util.h"
28    
29  int main(void) {  int main(int argc, const char ** argv) {
30  #ifdef __MINGW32__  #ifdef __MINGW32__
31    WSADATA data;    WSADATA data;
32    if (WSAStartup(MAKEWORD(1, 1), &data) != 0) {    if (WSAStartup(MAKEWORD(1, 1), &data) != 0) {
# Line 34  Line 34 
34    }    }
35  #endif  #endif
36    
37      assert(argc == 2);
38      uint16_t port = (uint16_t) atoi(argv[1]);
39    
40    SOCKET s = socket(PF_INET, SOCK_STREAM, 0);    SOCKET s = socket(PF_INET, SOCK_STREAM, 0);
41    assert(s != INVALID_SOCKET);    assert(s != INVALID_SOCKET);
42    
# Line 42  Line 45 
45    
46    struct sockaddr_in a;    struct sockaddr_in a;
47    a.sin_family = AF_INET;    a.sin_family = AF_INET;
48    a.sin_port = htons(8000);    a.sin_port = htons(port);
49    a.sin_addr.s_addr = htonl(INADDR_LOOPBACK);    a.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
50    int result = bind(s, (struct sockaddr *) &a, sizeof(a));    int result = bind(s, (struct sockaddr *) &a, sizeof(a));
51    assert(result == 0);    assert(result == 0);
# Line 102  Line 105 
105    
106      /* send response */      /* send response */
107      char * message;      char * message;
108      if (strcmp(url, "http://127.0.0.1:8000/lower") == 0 || strcmp(url, "/lower") == 0) {      if (strcmp(url, "/lower") == 0) {
109        message = "HTTP/1.1 200 OK\r\n"        message = "HTTP/1.1 200 OK\r\n"
110                  "Connection: close\r\n"                  "Connection: close\r\n"
111                  "Content-type: text/html\r\n"                  "Content-type: text/html\r\n"
# Line 117  Line 120 
120                  "0\r\n"                  "0\r\n"
121                  "\r\n";                  "\r\n";
122      }      }
123      else if (strcmp(url, "http://127.0.0.1:8000/upper") == 0 || strcmp(url, "/upper") == 0) {      else if (strcmp(url, "/upper") == 0) {
124        message = "HTTP/1.1 200 OK\r\n"        message = "HTTP/1.1 200 OK\r\n"
125                  "Connection: close\r\n"                  "Connection: close\r\n"
126                  "Content-type: text/html\r\n"                  "Content-type: text/html\r\n"
# Line 132  Line 135 
135                  "0\r\n"                  "0\r\n"
136                  "\r\n";                  "\r\n";
137      }      }
138      else if (strcmp(url, "http://127.0.0.1:8000/javascript") == 0 || strcmp(url, "/javascript") == 0) {      else if (strcmp(url, "/javascript") == 0) {
139        message = "HTTP/1.1 200 OK\r\n"        message = "HTTP/1.1 200 OK\r\n"
140                  "Connection: close\r\n"                  "Connection: close\r\n"
141                  "Content-Type: text/javascript\r\n"                  "Content-Type: text/javascript\r\n"
# Line 149  Line 152 
152                  "0\r\n"                  "0\r\n"
153                  "\r\n";                  "\r\n";
154      }      }
155      else if (strcmp(url, "http://127.0.0.1:8000/trailer") == 0 || strcmp(url, "/trailer") == 0) {      else if (strcmp(url, "/trailer") == 0) {
156        message = "HTTP/1.1 200 OK\r\n"        message = "HTTP/1.1 200 OK\r\n"
157                  "Connection: close\r\n"                  "Connection: close\r\n"
158                  "Content-type: text/html\r\n"                  "Content-type: text/html\r\n"
# Line 164  Line 167 
167                  "X-Bar: foo\r\n"                  "X-Bar: foo\r\n"
168                  "\r\n";                  "\r\n";
169      }      }
170      else if (strcmp(url, "http://127.0.0.1:8000/overflow") == 0 || strcmp(url, "/overflow") == 0) {      else if (strcmp(url, "/overflow") == 0) {
171        message = "HTTP/1.1 200 OK\r\n"        message = "HTTP/1.1 200 OK\r\n"
172                  "Connection: close\r\n"                  "Connection: close\r\n"
173                  "Content-type: text/html\r\n"                  "Content-type: text/html\r\n"
# Line 177  Line 180 
180                  "0\r\n"                  "0\r\n"
181                  "\r\n";                  "\r\n";
182      }      }
183      else if (strcmp(url, "http://127.0.0.1:8000/multiple") == 0 || strcmp(url, "/multiple") == 0) {      else if (strcmp(url, "/multiple") == 0) {
184        message = "HTTP/1.1 200 OK\r\n"        message = "HTTP/1.1 200 OK\r\n"
185                  "Connection: close\r\n"                  "Connection: close\r\n"
186                  "Content-type: text/html\r\n"                  "Content-type: text/html\r\n"

Legend:
Removed from v.609  
changed lines
  Added in v.610

  ViewVC Help
Powered by ViewVC 1.1.24