@@ -532,6 +532,8 @@ int make_http_soap_request(zval *this_ptr,
532
532
}
533
533
PG (allow_url_fopen ) = old_allow_url_fopen ;
534
534
535
+ bool client_trace = Z_TYPE_P (Z_CLIENT_TRACE_P (this_ptr )) == IS_TRUE ;
536
+
535
537
if (stream ) {
536
538
zval * cookies , * login , * password ;
537
539
zend_resource * ret = zend_register_resource (phpurl , le_url );
@@ -863,7 +865,7 @@ int make_http_soap_request(zval *this_ptr,
863
865
864
866
smart_str_append_const (& soap_headers , "\r\n" );
865
867
smart_str_0 (& soap_headers );
866
- if (Z_TYPE_P ( Z_CLIENT_TRACE_P ( this_ptr )) == IS_TRUE ) {
868
+ if (client_trace ) {
867
869
zval_ptr_dtor (Z_CLIENT_LAST_REQUEST_HEADERS_P (this_ptr ));
868
870
/* Need to copy the string here, as we continue appending to soap_headers below. */
869
871
ZVAL_STRINGL (Z_CLIENT_LAST_REQUEST_HEADERS_P (this_ptr ),
@@ -892,65 +894,78 @@ int make_http_soap_request(zval *this_ptr,
892
894
return FALSE;
893
895
}
894
896
895
- if (!return_value ) {
896
- php_stream_close (stream );
897
- convert_to_null (Z_CLIENT_HTTPSOCKET_P (this_ptr ));
898
- convert_to_null (Z_CLIENT_USE_PROXY_P (this_ptr ));
899
- smart_str_free (& soap_headers_z );
900
- return TRUE;
901
- }
897
+ http_headers = NULL ;
898
+ if (return_value || client_trace ) {
899
+ do {
900
+ http_headers = get_http_headers (stream );
901
+ if (!http_headers ) {
902
+ if (request != buf ) {
903
+ zend_string_release_ex (request , 0 );
904
+ }
905
+ php_stream_close (stream );
906
+ convert_to_null (Z_CLIENT_HTTPSOCKET_P (this_ptr ));
907
+ convert_to_null (Z_CLIENT_USE_PROXY_P (this_ptr ));
908
+ add_soap_fault (this_ptr , "HTTP" , "Error Fetching http headers" , NULL , NULL );
909
+ smart_str_free (& soap_headers_z );
910
+ return FALSE;
911
+ }
902
912
903
- do {
904
- http_headers = get_http_headers (stream );
905
- if (!http_headers ) {
906
- if (request != buf ) {
907
- zend_string_release_ex (request , 0 );
913
+ if (client_trace ) {
914
+ zval_ptr_dtor (Z_CLIENT_LAST_RESPONSE_HEADERS_P (this_ptr ));
915
+ ZVAL_STR_COPY (Z_CLIENT_LAST_RESPONSE_HEADERS_P (this_ptr ), http_headers );
908
916
}
909
- php_stream_close (stream );
910
- convert_to_null (Z_CLIENT_HTTPSOCKET_P (this_ptr ));
911
- convert_to_null (Z_CLIENT_USE_PROXY_P (this_ptr ));
912
- add_soap_fault (this_ptr , "HTTP" , "Error Fetching http headers" , NULL , NULL );
913
- smart_str_free (& soap_headers_z );
914
- return FALSE;
915
- }
916
917
917
- if (Z_TYPE_P (Z_CLIENT_TRACE_P (this_ptr )) == IS_TRUE ) {
918
- zval_ptr_dtor (Z_CLIENT_LAST_RESPONSE_HEADERS_P (this_ptr ));
919
- ZVAL_STR_COPY (Z_CLIENT_LAST_RESPONSE_HEADERS_P (this_ptr ), http_headers );
920
- }
918
+ /* Check to see what HTTP status was sent */
919
+ http_1_1 = 0 ;
920
+ http_status = 0 ;
921
+ http_version = get_http_header_value (ZSTR_VAL (http_headers ), "HTTP/" );
922
+ if (http_version ) {
923
+ char * tmp ;
921
924
922
- /* Check to see what HTTP status was sent */
923
- http_1_1 = 0 ;
924
- http_status = 0 ;
925
- http_version = get_http_header_value (ZSTR_VAL (http_headers ), "HTTP/" );
926
- if (http_version ) {
927
- char * tmp ;
925
+ if (!strncmp (http_version ,"1.1" , 3 )) {
926
+ http_1_1 = 1 ;
927
+ }
928
928
929
- if (!strncmp (http_version ,"1.1" , 3 )) {
930
- http_1_1 = 1 ;
931
- }
929
+ tmp = strstr (http_version ," " );
930
+ if (tmp != NULL ) {
931
+ tmp ++ ;
932
+ http_status = atoi (tmp );
933
+ }
934
+ tmp = strstr (tmp ," " );
935
+ if (tmp != NULL ) {
936
+ tmp ++ ;
937
+ if (http_msg ) {
938
+ efree (http_msg );
939
+ }
940
+ http_msg = estrdup (tmp );
941
+ }
942
+ efree (http_version );
932
943
933
- tmp = strstr (http_version ," " );
934
- if (tmp != NULL ) {
935
- tmp ++ ;
936
- http_status = atoi (tmp );
937
- }
938
- tmp = strstr (tmp ," " );
939
- if (tmp != NULL ) {
940
- tmp ++ ;
941
- if (http_msg ) {
942
- efree (http_msg );
944
+ /* Try and get headers again */
945
+ if (http_status == 100 ) {
946
+ zend_string_release_ex (http_headers , 0 );
943
947
}
944
- http_msg = estrdup (tmp );
945
948
}
946
- efree (http_version );
949
+ } while (http_status == 100 );
950
+ }
947
951
948
- /* Try and get headers again */
949
- if (http_status == 100 ) {
950
- zend_string_release_ex (http_headers , 0 );
951
- }
952
+ if (!return_value ) {
953
+ /* In this case, the headers were only fetched because client_trace was true. */
954
+ if (request != buf ) {
955
+ zend_string_release_ex (request , 0 );
956
+ }
957
+ php_stream_close (stream );
958
+ if (http_headers ) {
959
+ zend_string_release_ex (http_headers , 0 );
960
+ }
961
+ convert_to_null (Z_CLIENT_HTTPSOCKET_P (this_ptr ));
962
+ convert_to_null (Z_CLIENT_USE_PROXY_P (this_ptr ));
963
+ if (http_msg ) {
964
+ efree (http_msg );
952
965
}
953
- } while (http_status == 100 );
966
+ smart_str_free (& soap_headers_z );
967
+ return true;
968
+ }
954
969
955
970
/* Grab and send back every cookie */
956
971
0 commit comments