Skip to content

Commit 935776f

Browse files
committed
disable swoole_http_client, Fix #461
1 parent 7c8747f commit 935776f

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

php_swoole.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ void swoole_table_init(int module_number TSRMLS_DC);
294294
void swoole_lock_init(int module_number TSRMLS_DC);
295295
void swoole_atomic_init(int module_number TSRMLS_DC);
296296
void swoole_client_init(int module_number TSRMLS_DC);
297+
#ifdef SW_HTTP_CLIENT_ENABLE
297298
void swoole_http_client_init(int module_number TSRMLS_DC);
299+
#endif
298300
void swoole_process_init(int module_number TSRMLS_DC);
299301
void swoole_http_init(int module_number TSRMLS_DC);
300302
void swoole_websocket_init(int module_number TSRMLS_DC);

swoole.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,9 @@ PHP_MINIT_FUNCTION(swoole)
630630
swoole_init();
631631

632632
swoole_client_init(module_number TSRMLS_CC);
633+
#ifdef SW_HTTP_CLIENT_ENABLE
633634
swoole_http_client_init(module_number TSRMLS_CC);
635+
#endif
634636
swoole_async_init(module_number TSRMLS_CC);
635637
swoole_process_init(module_number TSRMLS_CC);
636638
swoole_table_init(module_number TSRMLS_CC);

swoole_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@
211211

212212
#define SW_DNS_LOOKUP_USE_THREAD
213213

214+
//#define SW_HTTP_CLIENT_ENABLE
215+
214216
#define SW_HTTP_SERVER_SOFTWARE "swoole-http-server"
215217
#define SW_HTTP_BAD_REQUEST "<h1>400 Bad Request</h1>\r\n"
216218
#define SW_HTTP_PARAM_MAX_NUM 128

swoole_http_client.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "thirdparty/php_http_parser.h"
1919
#include "ext/standard/basic_functions.h"
2020

21+
#ifdef SW_HTTP_CLIENT_ENABLE
22+
2123
#define SW_FD_HTTP_CLIENT (SW_FD_USER+1)
2224

2325
typedef struct
@@ -43,6 +45,8 @@ typedef struct
4345
char *tmp_header_field_name;
4446
zend_size_t tmp_header_field_name_len;
4547

48+
char *body;
49+
4650
php_http_parser parser;
4751

4852
int phase; //0 wait 1 ready 2 busy
@@ -698,15 +702,13 @@ static PHP_METHOD(swoole_http_client, __construct)
698702
return;
699703
}
700704

701-
if(host_len <= 0)
705+
if (host_len <= 0)
702706
{
703707
swoole_php_fatal_error(E_ERROR, "host is empty.");
704708
RETURN_FALSE;
705709
}
706710

707-
zend_update_property_stringl(
708-
swoole_http_client_class_entry_ptr,
709-
getThis(), ZEND_STRL("host"), host, host_len TSRMLS_CC);
711+
zend_update_property_stringl(swoole_http_client_class_entry_ptr, getThis(), ZEND_STRL("host"), host, host_len TSRMLS_CC);
710712

711713
zend_update_property_long(
712714
swoole_http_client_class_entry_ptr,
@@ -1017,8 +1019,8 @@ static int http_client_parser_on_body(php_http_parser *parser, const char *at, s
10171019
TSRMLS_FETCH_FROM_CTX(sw_thread_ctx ? sw_thread_ctx : NULL);
10181020
#endif
10191021

1020-
http_client* http = (http_client*)parser->data;
1021-
zval* zobject = (zval*)http->cli->socket->object;
1022+
http_client* http = (http_client*) parser->data;
1023+
zval* zobject = (zval*) http->cli->socket->object;
10221024

10231025
zval *body = sw_zend_read_property(swoole_http_client_class_entry_ptr, zobject, ZEND_STRL("body"), 0 TSRMLS_CC);
10241026
zval *tmp;
@@ -1035,6 +1037,7 @@ static int http_client_parser_on_message_complete(php_http_parser *parser)
10351037
#if PHP_MAJOR_VERSION < 7
10361038
TSRMLS_FETCH_FROM_CTX(sw_thread_ctx ? sw_thread_ctx : NULL);
10371039
#endif
1040+
10381041
http_client* http = (http_client*)parser->data;
10391042
zval* zobject = (zval*)http->cli->socket->object;
10401043

@@ -1044,7 +1047,6 @@ static int http_client_parser_on_message_complete(php_http_parser *parser)
10441047
http->phase = 1;
10451048
}
10461049

1047-
10481050
zval *retval;
10491051
zval *zcallback;
10501052

@@ -1072,3 +1074,5 @@ static int http_client_parser_on_message_complete(php_http_parser *parser)
10721074

10731075
return 0;
10741076
}
1077+
1078+
#endif

0 commit comments

Comments
 (0)