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
2325typedef  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