/[jscoverage]/trunk/tests/http-client-close-after-request.c
ViewVC logotype

Annotation of /trunk/tests/http-client-close-after-request.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 114 - (hide annotations)
Sat May 31 21:39:39 2008 UTC (11 years, 4 months ago) by siliconforks
File MIME type: text/plain
File size: 1656 byte(s)
Add tests for jscoverage-server.

1 siliconforks 114 /*
2     http-client-close-after-request.c - HTTP client that closes connection after sending request
3     Copyright (C) 2008 siliconforks.com
4    
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9    
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     GNU General Public License for more details.
14    
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18     */
19    
20     #include <assert.h>
21     #include <stdio.h>
22     #include <stdlib.h>
23     #include <string.h>
24    
25     #include <netinet/in.h>
26     #include <sys/socket.h>
27     #include <unistd.h>
28    
29     #include "http-server.h"
30    
31     int main(void) {
32     int result;
33    
34     struct sockaddr_in a;
35     a.sin_family = AF_INET;
36     a.sin_port = htons(8000);
37     a.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
38    
39     int s = socket(PF_INET, SOCK_STREAM, 0);
40     assert(s > 0);
41    
42     result = connect(s, (struct sockaddr *) &a, sizeof(a));
43     assert(result == 0);
44    
45     /* send request */
46     char * message = "GET http://127.0.0.1:8000/ HTTP/1.1\r\nConnection: close\r\nHost: 127.0.0.1:8000\r\n\r\n";
47     size_t message_length = strlen(message);
48     ssize_t bytes_sent = send(s, message, message_length, 0);
49     assert(bytes_sent == (ssize_t) message_length);
50    
51     close(s);
52     return 0;
53     }

  ViewVC Help
Powered by ViewVC 1.1.24