Skip to content

Commit 1af4b35

Browse files
committed
ext/soap/php_http.c: Refactor basic_authentication()
1 parent bf869a5 commit 1af4b35

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

ext/soap/php_http.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,29 +53,29 @@ bool proxy_authentication(const zval* this_ptr, smart_str* soap_headers)
5353
}
5454

5555
/* HTTP Authentication */
56-
int basic_authentication(zval* this_ptr, smart_str* soap_headers)
56+
bool basic_authentication(const zval* this_ptr, smart_str* soap_headers)
5757
{
58-
zval *login = Z_CLIENT_LOGIN_P(this_ptr);
59-
zval *use_digest = Z_CLIENT_USE_DIGEST_P(this_ptr);
58+
const zval *login = Z_CLIENT_LOGIN_P(this_ptr);
59+
const zval *use_digest = Z_CLIENT_USE_DIGEST_P(this_ptr);
6060
if (Z_TYPE_P(login) == IS_STRING && Z_TYPE_P(use_digest) != IS_TRUE) {
6161
smart_str auth = {0};
6262
smart_str_append(&auth, Z_STR_P(login));
6363
smart_str_appendc(&auth, ':');
6464

65-
zval *password = Z_CLIENT_PASSWORD_P(this_ptr);
65+
const zval *password = Z_CLIENT_PASSWORD_P(this_ptr);
6666
if (Z_TYPE_P(password) == IS_STRING) {
6767
smart_str_append(&auth, Z_STR_P(password));
6868
}
6969
smart_str_0(&auth);
70-
zend_string *buf = php_base64_encode((unsigned char*)ZSTR_VAL(auth.s), ZSTR_LEN(auth.s));
70+
zend_string *buf = php_base64_encode_str(auth.s);
7171
smart_str_append_const(soap_headers, "Authorization: Basic ");
7272
smart_str_append(soap_headers, buf);
7373
smart_str_append_const(soap_headers, "\r\n");
74-
zend_string_release_ex(buf, 0);
74+
zend_string_release_ex(buf, false);
7575
smart_str_free(&auth);
76-
return 1;
76+
return true;
7777
}
78-
return 0;
78+
return false;
7979
}
8080

8181
static void http_context_add_header(const char *s,

ext/soap/php_http.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ int make_http_soap_request(zval *this_ptr,
2727
zval *response);
2828

2929
bool proxy_authentication(const zval* this_ptr, smart_str* soap_headers);
30-
int basic_authentication(zval* this_ptr, smart_str* soap_headers);
30+
bool basic_authentication(const zval* this_ptr, smart_str* soap_headers);
3131
void http_context_headers(php_stream_context* context,
3232
bool has_authorization,
3333
bool has_proxy_authorization,

0 commit comments

Comments
 (0)