This commit is contained in:
parent
9355fcd309
commit
46a13f7aa3
@ -979,6 +979,24 @@ static void handle_write_event(connection_t *conn) {
|
|||||||
int written = connection_do_write(conn);
|
int written = connection_do_write(conn);
|
||||||
|
|
||||||
if (buffer_available_read(&conn->write_buf) == 0) {
|
if (buffer_available_read(&conn->write_buf) == 0) {
|
||||||
|
if (conn->type == CONN_TYPE_UPSTREAM && !conn->ssl && conn->pair) {
|
||||||
|
connection_t *client = conn->pair;
|
||||||
|
size_t buffered = buffer_available_read(&client->read_buf);
|
||||||
|
if (buffered > 0) {
|
||||||
|
char *data_start = client->read_buf.data + client->read_buf.head;
|
||||||
|
if (!(buffered >= 4 && http_is_request_start(data_start, buffered))) {
|
||||||
|
if (buffer_ensure_capacity(&conn->write_buf, buffered) == 0) {
|
||||||
|
memcpy(conn->write_buf.data + conn->write_buf.tail, data_start, buffered);
|
||||||
|
conn->write_buf.tail += buffered;
|
||||||
|
buffer_consume(&client->read_buf, buffered);
|
||||||
|
log_debug("Forwarding %zu bytes of buffered request data to upstream fd %d", buffered, conn->fd);
|
||||||
|
connection_modify_epoll(conn->fd, EPOLLIN | EPOLLOUT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (conn->write_shutdown) {
|
if (conn->write_shutdown) {
|
||||||
if (conn->half_closed) {
|
if (conn->half_closed) {
|
||||||
connection_close(conn->fd);
|
connection_close(conn->fd);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user