Skip to content

Commit fc849bf

Browse files
committed
http_client: Add a fallback for writev
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent ad3084e commit fc849bf

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

src/flb_http_client.c

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,12 +1504,38 @@ int flb_http_do_request(struct flb_http_client *c, size_t *bytes)
15041504
2,
15051505
&bytes_header);
15061506
if (ret == -1) {
1507-
flb_errno();
1508-
return FLB_HTTP_ERROR;
1509-
}
1507+
if (errno == ENOMEM && bytes_header == 0) {
1508+
ret = flb_io_net_write(c->u_conn,
1509+
c->header_buf, c->header_len,
1510+
&bytes_header);
1511+
if (ret == -1) {
1512+
if (errno != 0) {
1513+
flb_errno();
1514+
}
1515+
return FLB_HTTP_ERROR;
1516+
}
15101517

1511-
bytes_body = bytes_header - c->header_len;
1512-
bytes_header = c->header_len;
1518+
ret = flb_io_net_write(c->u_conn,
1519+
c->body_buf, c->body_len,
1520+
&bytes_body);
1521+
if (ret == -1) {
1522+
if (errno != 0) {
1523+
flb_errno();
1524+
}
1525+
return FLB_HTTP_ERROR;
1526+
}
1527+
}
1528+
else {
1529+
if (errno != 0) {
1530+
flb_errno();
1531+
}
1532+
return FLB_HTTP_ERROR;
1533+
}
1534+
}
1535+
else {
1536+
bytes_body = bytes_header - c->header_len;
1537+
bytes_header = c->header_len;
1538+
}
15131539
}
15141540
else {
15151541
/* Write the header */

0 commit comments

Comments
 (0)