1 | #include<ByteOrder.h>
|
---|
2 | #include<NetAddress.h>
|
---|
3 | #include<Message.h>
|
---|
4 | #include<NetBuffer.h>
|
---|
5 | #include<NetEndpoint.h>
|
---|
6 | #include<sys/socket.h>
|
---|
7 | #include<netinet/in.h>
|
---|
8 | #include<arpa/inet.h>
|
---|
9 | #include<stdio.h>
|
---|
10 | #include<string.h>
|
---|
11 |
|
---|
12 | /*
|
---|
13 | A Very abstract level implementation
|
---|
14 | that proves that the http reqeust
|
---|
15 | response works over haiku
|
---|
16 | */
|
---|
17 |
|
---|
18 |
|
---|
19 | class http_handler
|
---|
20 | {
|
---|
21 | BNetAddress *obj;
|
---|
22 | BNetEndpoint *endpoint;
|
---|
23 | public:
|
---|
24 | BNetBuffer *receive;
|
---|
25 | http_handler(){
|
---|
26 |
|
---|
27 | receive = new BNetBuffer(512);
|
---|
28 |
|
---|
29 | }
|
---|
30 | http_handler(const char *hostname,
|
---|
31 | unsigned short port)
|
---|
32 | {
|
---|
33 | }
|
---|
34 | };
|
---|
35 | int
|
---|
36 | main()
|
---|
37 | {
|
---|
38 |
|
---|
39 | BNetAddress obj(inet_addr("172.31.16.10"),8080);
|
---|
40 | BNetEndpoint ep(SOCK_STREAM);
|
---|
41 | BNetBuffer buffer(1024);
|
---|
42 | http_handler hh;
|
---|
43 | buffer.AppendString("GET http://www.rediff.com HTTP/1.1\r\n\r\n");
|
---|
44 | ep.Connect(obj);
|
---|
45 | ep.Send(buffer ,0);
|
---|
46 |
|
---|
47 | whilei (ep.Receive(hh.receive->Data() ,512 ,0)!=0){
|
---|
48 | printf("%s\n",hh.receive->Data());
|
---|
49 | hh.receive->RemoveData(hh.receive->Data(),512); //Flush the buffer
|
---|
50 | }
|
---|
51 | return 0;
|
---|
52 | }
|
---|
53 |
|
---|