src/server/proxy/httpclient.c

changeset 673
144bdc33fdb6
parent 672
226bfd584075
child 674
6a031133a498
equal deleted inserted replaced
672:226bfd584075 673:144bdc33fdb6
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "httpclient.h" 29 #include "httpclient.h"
30
31 #include "../util/socket.h"
30 32
31 #include <cx/buffer.h> 33 #include <cx/buffer.h>
32 #include <cx/string.h> 34 #include <cx/string.h>
33 #include <stdlib.h> 35 #include <stdlib.h>
34 #include <string.h> 36 #include <string.h>
158 int socketfd = socket(AF_INET, SOCK_STREAM, 0); 160 int socketfd = socket(AF_INET, SOCK_STREAM, 0);
159 if(socketfd < 0) { 161 if(socketfd < 0) {
160 return 1; 162 return 1;
161 } 163 }
162 164
163 int flags; 165 if(util_socket_setnonblock(socketfd, 1)) {
164 if ((flags = fcntl(socketfd, F_GETFL, 0)) == -1) {
165 flags = 0;
166 }
167 if (fcntl(socketfd, F_SETFL, flags | O_NONBLOCK) != 0) {
168 close(socketfd); 166 close(socketfd);
169 return 1; 167 return 1;
170 } 168 }
169
171 client->socketfd = socketfd; 170 client->socketfd = socketfd;
172 171
173 client->writeev.cookie = client; 172 client->writeev.cookie = client;
174 client->writeev.fn = client_connected; 173 client->writeev.fn = client_connected;
175 174
351 350
352 client->req_buffer_pos += w; 351 client->req_buffer_pos += w;
353 352
354 return client->req_buffer_pos < client->req_buffer_len; 353 return client->req_buffer_pos < client->req_buffer_len;
355 } 354 }
355
356
357
358 /* --------------------------------- Tests --------------------------------- */
359
360 static CX_TEST(test_http_client_send_request) {
361 CX_TEST_DO {
362
363 }
364 }
365
366 void http_client_add_tests(CxTestSuite *suite) {
367 cx_test_register(suite, test_http_client_send_request);
368 }

mercurial