Skip to content

Commit e0c75d4

Browse files
committed
ext/soap/php_http.c: Bring variable declaration closer to use site
1 parent bd6b61d commit e0c75d4

File tree

1 file changed

+25
-29
lines changed

1 file changed

+25
-29
lines changed

ext/soap/php_http.c

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,12 @@ bool make_http_soap_request(
347347
int use_proxy = 0;
348348
int use_ssl;
349349
zend_string *http_body;
350-
char *content_type, *http_version;
351350
bool http_close;
352351
zend_string *http_headers;
353-
char *connection;
354352
bool http_1_1;
355353
int http_status;
356354
bool content_type_xml = false;
357355
zend_long redirect_max = 20;
358-
char *content_encoding;
359356
char *http_msg = NULL;
360357
bool old_allow_url_fopen;
361358
php_stream_context *context = NULL;
@@ -957,7 +954,7 @@ bool make_http_soap_request(
957954
/* Check to see what HTTP status was sent */
958955
http_1_1 = false;
959956
http_status = 0;
960-
http_version = get_http_header_value(http_headers, "HTTP/");
957+
char *http_version = get_http_header_value(http_headers, "HTTP/");
961958
if (http_version) {
962959
char *tmp;
963960

@@ -1086,16 +1083,16 @@ bool make_http_soap_request(
10861083
if (http_1_1) {
10871084
http_close = false;
10881085
if (use_proxy && !use_ssl) {
1089-
connection = get_http_header_value(http_headers, "Proxy-Connection:");
1090-
if (connection) {
1091-
if (strncasecmp(connection, "close", sizeof("close")-1) == 0) {
1086+
char *proxy_connection = get_http_header_value(http_headers, "Proxy-Connection:");
1087+
if (proxy_connection) {
1088+
if (strncasecmp(proxy_connection, "close", sizeof("close")-1) == 0) {
10921089
http_close = true;
10931090
}
1094-
efree(connection);
1091+
efree(proxy_connection);
10951092
}
10961093
}
10971094
if (!http_close) {
1098-
connection = get_http_header_value(http_headers, "Connection:");
1095+
char *connection = get_http_header_value(http_headers, "Connection:");
10991096
if (connection) {
11001097
if (strncasecmp(connection, "close", sizeof("close")-1) == 0) {
11011098
http_close = true;
@@ -1106,16 +1103,16 @@ bool make_http_soap_request(
11061103
} else {
11071104
http_close = true;
11081105
if (use_proxy && !use_ssl) {
1109-
connection = get_http_header_value(http_headers, "Proxy-Connection:");
1110-
if (connection) {
1111-
if (strncasecmp(connection, "Keep-Alive", sizeof("Keep-Alive")-1) == 0) {
1106+
char *proxy_connection = get_http_header_value(http_headers, "Proxy-Connection:");
1107+
if (proxy_connection) {
1108+
if (strncasecmp(proxy_connection, "Keep-Alive", sizeof("Keep-Alive")-1) == 0) {
11121109
http_close = false;
11131110
}
1114-
efree(connection);
1111+
efree(proxy_connection);
11151112
}
11161113
}
11171114
if (http_close) {
1118-
connection = get_http_header_value(http_headers, "Connection:");
1115+
char *connection = get_http_header_value(http_headers, "Connection:");
11191116
if (connection) {
11201117
if (strncasecmp(connection, "Keep-Alive", sizeof("Keep-Alive")-1) == 0) {
11211118
http_close = false;
@@ -1278,7 +1275,7 @@ bool make_http_soap_request(
12781275
smart_str_free(&soap_headers_z);
12791276

12801277
/* Check and see if the server even sent a xml document */
1281-
content_type = get_http_header_value(http_headers, "Content-Type:");
1278+
char *content_type = get_http_header_value(http_headers, "Content-Type:");
12821279
if (content_type) {
12831280
char *pos = NULL;
12841281
int cmplen;
@@ -1308,7 +1305,7 @@ bool make_http_soap_request(
13081305
}
13091306

13101307
/* Decompress response */
1311-
content_encoding = get_http_header_value(http_headers, "Content-Encoding:");
1308+
char *content_encoding = get_http_header_value(http_headers, "Content-Encoding:");
13121309
if (content_encoding) {
13131310
zval retval;
13141311
zval params[1];
@@ -1455,32 +1452,31 @@ static char *get_http_header_value(zend_string *headers, char *type)
14551452
static zend_string* get_http_body(php_stream *stream, bool close, zend_string *headers)
14561453
{
14571454
zend_string *http_buf = NULL;
1458-
char *header;
14591455
bool header_close = close;
14601456
bool header_chunked = false;
14611457
int header_length = 0;
14621458
size_t http_buf_size = 0;
14631459

14641460
if (!close) {
1465-
header = get_http_header_value(headers, "Connection:");
1466-
if (header) {
1467-
if (!strncasecmp(header, "close", sizeof("close")-1)) {
1461+
char *connection = get_http_header_value(headers, "Connection:");
1462+
if (connection) {
1463+
if (!strncasecmp(connection, "close", sizeof("close")-1)) {
14681464
header_close = true;
14691465
}
1470-
efree(header);
1466+
efree(connection);
14711467
}
14721468
}
1473-
header = get_http_header_value(headers, "Transfer-Encoding:");
1474-
if (header) {
1475-
if (!strncasecmp(header, "chunked", sizeof("chunked")-1)) {
1469+
char *transfer_encoding = get_http_header_value(headers, "Transfer-Encoding:");
1470+
if (transfer_encoding) {
1471+
if (!strncasecmp(transfer_encoding, "chunked", sizeof("chunked")-1)) {
14761472
header_chunked = true;
14771473
}
1478-
efree(header);
1474+
efree(transfer_encoding);
14791475
}
1480-
header = get_http_header_value(headers, "Content-Length:");
1481-
if (header) {
1482-
header_length = atoi(header);
1483-
efree(header);
1476+
char *content_length = get_http_header_value(headers, "Content-Length:");
1477+
if (content_length) {
1478+
header_length = atoi(content_length);
1479+
efree(content_length);
14841480
if (!header_length && !header_chunked) {
14851481
/* Empty response */
14861482
return ZSTR_EMPTY_ALLOC();

0 commit comments

Comments
 (0)