Skip to content

Commit db34e46

Browse files
committed
Merge http proxy changes and improve.
1 parent 47ad5e3 commit db34e46

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

include/client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct _http_proxy
5555
char *target_host;
5656
int l_target_host;
5757
int target_port;
58-
char buf[600];
58+
char buf[512];
5959
};
6060

6161
typedef struct _swClient

swoole_http_client_coro.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,19 +613,20 @@ void PHPHttpClient::set(zval *zset = nullptr)
613613
php_swoole_client_coro_check_setting(socket, zsettings);
614614
if (socket->http_proxy)
615615
{
616-
zval *zrequest_headers = sw_zend_read_property(swoole_http_client_coro_ce_ptr, zobject, ZEND_STRL("requestHeaders"), 0);
617616
if (socket->http_proxy->password)
618617
{
619-
char _buf1[128];
620-
char _buf2[256];
621-
int _n1 = snprintf(_buf1, sizeof(_buf1), "%*s:%*s",
618+
char _buf1[256];
619+
int _n1 = snprintf(
620+
_buf1, sizeof(_buf1), "%*s:%*s",
622621
socket->http_proxy->l_user, socket->http_proxy->user,
623622
socket->http_proxy->l_password, socket->http_proxy->password
624623
);
625624
zend_string *str = php_base64_encode((const unsigned char *) _buf1, _n1);
626-
int _n2 = snprintf(_buf2, sizeof(_buf2), "Basic %*s", (int)str->len, str->val);
625+
snprintf(
626+
socket->http_proxy->buf, sizeof(socket->http_proxy->buf),
627+
"Proxy-Authorization:Basic %*s", (int)str->len, str->val
628+
);
627629
zend_string_free(str);
628-
add_assoc_stringl_ex(zrequest_headers, ZEND_STRL("Proxy-Authorization"), _buf2, _n2);
629630
}
630631
}
631632
}

0 commit comments

Comments
 (0)