Skip to content

Commit abb509b

Browse files
committed
soap: Reduce duplication around Close/Keep-Alive checking
1 parent 9a73c00 commit abb509b

1 file changed

Lines changed: 16 additions & 23 deletions

File tree

ext/soap/php_http.c

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ int make_http_soap_request(
354354
size_t cookie_len;
355355
int http_close;
356356
zend_string *http_headers;
357-
char *connection;
358357
int http_1_1;
359358
int http_status;
360359
int content_type_xml = 0;
@@ -1072,43 +1071,37 @@ int make_http_soap_request(
10721071
/* See if the server requested a close */
10731072
if (http_1_1) {
10741073
http_close = FALSE;
1074+
char *connection = NULL;
1075+
10751076
if (use_proxy && !use_ssl) {
10761077
connection = get_http_header_value(ZSTR_VAL(http_headers), "Proxy-Connection:");
1077-
if (connection) {
1078-
if (strncasecmp(connection, "close", sizeof("close")-1) == 0) {
1079-
http_close = TRUE;
1080-
}
1081-
efree(connection);
1082-
}
10831078
}
10841079
if (http_close == FALSE) {
10851080
connection = get_http_header_value(ZSTR_VAL(http_headers), "Connection:");
1086-
if (connection) {
1087-
if (strncasecmp(connection, "close", sizeof("close")-1) == 0) {
1088-
http_close = TRUE;
1089-
}
1090-
efree(connection);
1081+
}
1082+
1083+
if (connection) {
1084+
if (strncasecmp(connection, "close", sizeof("close")-1) == 0) {
1085+
http_close = TRUE;
10911086
}
1087+
efree(connection);
10921088
}
10931089
} else {
10941090
http_close = TRUE;
1091+
char *connection = NULL;
1092+
10951093
if (use_proxy && !use_ssl) {
10961094
connection = get_http_header_value(ZSTR_VAL(http_headers), "Proxy-Connection:");
1097-
if (connection) {
1098-
if (strncasecmp(connection, "Keep-Alive", sizeof("Keep-Alive")-1) == 0) {
1099-
http_close = FALSE;
1100-
}
1101-
efree(connection);
1102-
}
11031095
}
11041096
if (http_close == TRUE) {
11051097
connection = get_http_header_value(ZSTR_VAL(http_headers), "Connection:");
1106-
if (connection) {
1107-
if (strncasecmp(connection, "Keep-Alive", sizeof("Keep-Alive")-1) == 0) {
1108-
http_close = FALSE;
1109-
}
1110-
efree(connection);
1098+
}
1099+
1100+
if (connection) {
1101+
if (strncasecmp(connection, "Keep-Alive", sizeof("Keep-Alive")-1) == 0) {
1102+
http_close = FALSE;
11111103
}
1104+
efree(connection);
11121105
}
11131106
}
11141107

0 commit comments

Comments
 (0)