if (uh->uc.url->port)
port = uh->uc.url->port;
- fd = usock(USOCK_TCP | USOCK_NONBLOCK, uh->uc.url->host, port);
+ memset(&uh->uc.remote_addr, 0, sizeof(uh->uc.remote_addr));
+
+ fd = usock_inet(USOCK_TCP | USOCK_NONBLOCK, uh->uc.url->host, port, &uh->uc.remote_addr);
if (fd < 0)
return -1;
ustream_fd_init(&uh->ufd, fd);
- memset(&uh->uc.local_addr, 0, sizeof(uh->uc.local_addr));
- memset(&uh->uc.remote_addr, 0, sizeof(uh->uc.remote_addr));
-
sl = sizeof(uh->uc.local_addr);
+ memset(&uh->uc.local_addr, 0, sl);
getsockname(fd, &uh->uc.local_addr.sa, &sl);
- getpeername(fd, &uh->uc.remote_addr.sa, &sl);
return 0;
}
static void uclient_http_init_request(struct uclient_http *uh)
{
+ uh->seq++;
uclient_http_reset_state(uh);
blob_buf_init(&uh->meta, 0);
}
url->location, url->host);
blobmsg_for_each_attr(cur, uh->headers.head, rem)
- ustream_printf(uh->us, "%s: %s\n", blobmsg_name(cur), (char *) blobmsg_data(cur));
+ ustream_printf(uh->us, "%s: %s\r\n", blobmsg_name(cur), (char *) blobmsg_data(cur));
if (uh->req_type == REQ_POST || uh->req_type == REQ_PUT)
ustream_printf(uh->us, "Transfer-Encoding: chunked\r\n");
static void uclient_http_headers_complete(struct uclient_http *uh)
{
enum auth_type auth_type = uh->auth_type;
+ int seq = uh->uc.seq;
uh->state = HTTP_STATE_RECV_DATA;
uh->uc.meta = uh->meta.head;
if (uh->uc.cb->header_done)
uh->uc.cb->header_done(&uh->uc);
- if (uh->eof)
+ if (uh->eof || seq != uh->uc.seq)
return;
if (uh->req_type == REQ_HEAD || uh->uc.status_code == 204) {
uh->ussl.notify_error = uclient_ssl_notify_error;
uh->ussl.notify_verify_error = uclient_ssl_notify_verify_error;
uh->ussl.notify_connected = uclient_ssl_notify_connected;
+ uh->ussl.server_name = uh->uc.url->host;
uh->ssl_ops->init(&uh->ussl, &uh->ufd.stream, uh->ssl_ctx, false);
uh->ssl_ops->set_peer_cn(&uh->ussl, uh->uc.url->host);