1
0
mirror of https://github.com/php/php-src.git synced 2026-04-25 00:48:25 +02:00

HTTP Authentication was implemented

This commit is contained in:
Dmitry Stogov
2004-01-08 09:56:49 +00:00
parent 962edd2d2e
commit ecbad181b9
3 changed files with 41 additions and 3 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ Transport
+ support for https://
- support for persistent HTTP connections (keep_alive)
- support for HTTP compression (gzip,x-gzip,defalte)
- support for HTTP athentication
+ support for HTTP authentication
- support for HTTP proxies
- transport abstraction layer
+20 -2
View File
@@ -1,4 +1,5 @@
#include "php_soap.h"
#include "ext/standard/base64.h"
static char *get_http_header_value(char *headers, char *type);
static int get_http_body(php_stream *socketd, char *headers, char **response, int *out_size TSRMLS_DC);
@@ -112,7 +113,7 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *soapaction TSRMLS_
}
if (stream) {
zval **cookies;
zval **cookies, **login, **password;
smart_str_append_const(&soap_headers, "POST ");
smart_str_appends(&soap_headers, phpurl->path);
@@ -132,7 +133,24 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *soapaction TSRMLS_
smart_str_appends(&soap_headers, soapaction);
smart_str_append_const(&soap_headers, "\"\r\n");
/* TODO: Add authentication */
/* HTTP Authentication */
if(zend_hash_find(Z_OBJPROP_P(this_ptr), "_login", sizeof("_login"), (void **)&login) == SUCCESS) {
char* buf;
int len;
smart_str auth = {0};
smart_str_appendl(&auth, Z_STRVAL_PP(login), Z_STRLEN_PP(login));
smart_str_appendc(&auth, ':');
if(zend_hash_find(Z_OBJPROP_P(this_ptr), "_password", sizeof("_password"), (void **)&password) == SUCCESS) {
smart_str_appendl(&auth, Z_STRVAL_PP(password), Z_STRLEN_PP(password));
}
buf = php_base64_encode(auth.c, auth.len, &len);
smart_str_append_const(&soap_headers, "Authorization: Basic ");
smart_str_appendl(&soap_headers, buf, len);
smart_str_append_const(&soap_headers, "\r\n");
efree(buf);
smart_str_free(&auth);
}
/* Send cookies along with request */
if(zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+20
View File
@@ -84,6 +84,7 @@ PHP_METHOD(soapobject, __style);
PHP_METHOD(soapobject, __isfault);
PHP_METHOD(soapobject, __getfault);
PHP_METHOD(soapobject, __call);
PHP_METHOD(soapobject, __login);
PHP_METHOD(soapobject, __trace);
PHP_METHOD(soapobject, __getfunctions);
PHP_METHOD(soapobject, __gettypes);
@@ -133,6 +134,7 @@ static zend_function_entry soap_client_functions[] = {
PHP_ME(soapobject, __getfault, NULL, 0)
PHP_ME(soapobject, __use, NULL, 0)
PHP_ME(soapobject, __style, NULL, 0)
PHP_ME(soapobject, __login, NULL, 0)
PHP_ME(soapobject, __call, NULL, 0)
PHP_ME(soapobject, __trace, NULL, 0)
PHP_ME(soapobject, __getlastrequest, NULL, 0)
@@ -1481,6 +1483,24 @@ zend_try {
SOAP_GLOBAL(sdl) = NULL;
}
PHP_METHOD(soapobject, __login)
{
char *login_name;
char *login_pass;
int login_name_len;
int login_pass_len;
zval* thisObj;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
&login_name, &login_name_len, &login_pass, &login_pass_len) == FAILURE) {
return;
}
GET_THIS_OBJECT(thisObj);
add_property_stringl(thisObj,"_login",login_name,login_name_len, 1);
add_property_stringl(thisObj,"_password",login_pass,login_pass_len, 1);
}
PHP_METHOD(soapobject, __call)
{
char *function, *soap_action, *uri;