| 120 CxBuffer buf; |
120 CxBuffer buf; |
| 121 if(cxBufferInit(&buf, cxDefaultAllocator, NULL, 1024, CX_BUFFER_AUTO_EXTEND)) { |
121 if(cxBufferInit(&buf, cxDefaultAllocator, NULL, 1024, CX_BUFFER_AUTO_EXTEND)) { |
| 122 return 1; |
122 return 1; |
| 123 } |
123 } |
| 124 |
124 |
| |
125 if(client->method) { |
| |
126 cxBufferPutString(&buf, "GET "); |
| |
127 } else { |
| |
128 cxBufferPutString(&buf, client->method); |
| |
129 } |
| |
130 cxBufferPutString(&buf, client->uri ? client->uri : "/"); |
| |
131 cxBufferPutString(&buf, " HTTP/1.1\r\n"); |
| 125 |
132 |
| |
133 HeaderArray *hdr = client->request_headers; |
| |
134 while(hdr) { |
| |
135 for(int i=0;i<hdr->len;i++) { |
| |
136 cxBufferPutString(&buf, hdr->headers[i].name); |
| |
137 cxBufferPutString(&buf, ": "); |
| |
138 cxBufferPutString(&buf, hdr->headers[i].value); |
| |
139 cxBufferPutString(&buf, "\r\n"); |
| |
140 } |
| |
141 hdr = hdr->next; |
| |
142 } |
| |
143 cxBufferPutString(&buf, "\r\n"); |
| |
144 client->req_buffer = buf.space; |
| |
145 client->req_buffer_len = buf.size; |
| 126 |
146 |
| 127 return 0; |
147 return 0; |
| 128 } |
148 } |
| 129 |
149 |
| 130 static int client_connected(EventHandler *ev, Event *event) { |
150 static int client_connected(EventHandler *ev, Event *event) { |