You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2006/05/19 19:19:32 UTC

svn commit: r407856 - in /webservices/axis2/trunk/c: include/ modules/core/transport/http/sender/ test/core/transport/http/

Author: sahan
Date: Fri May 19 10:19:32 2006
New Revision: 407856

URL: http://svn.apache.org/viewvc?rev=407856&view=rev
Log:
Adding proxy supprt for the HTTP transport

Modified:
    webservices/axis2/trunk/c/include/axis2_http_client.h
    webservices/axis2/trunk/c/include/axis2_http_transport.h
    webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c
    webservices/axis2/trunk/c/test/core/transport/http/test_http_transport.c

Modified: webservices/axis2/trunk/c/include/axis2_http_client.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_http_client.h?rev=407856&r1=407855&r2=407856&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_http_client.h (original)
+++ webservices/axis2/trunk/c/include/axis2_http_client.h Fri May 19 10:19:32 2006
@@ -70,6 +70,13 @@
     int (AXIS2_CALL *get_timeout) (axis2_http_client_t *client, 
                     axis2_env_t **env);
 	
+    axis2_status_t (AXIS2_CALL *set_proxy) (axis2_http_client_t *client, 
+                    axis2_env_t **env, axis2_char_t *proxy_host,
+                    int proxy_port);
+	
+    axis2_char_t* (AXIS2_CALL *get_proxy) (axis2_http_client_t *client, 
+                    axis2_env_t **env);
+	
     axis2_status_t (AXIS2_CALL *free) (axis2_http_client_t *client, 
                     axis2_env_t **env);
 };
@@ -112,6 +119,11 @@
 								timeout))
 #define AXIS2_HTTP_CLIENT_GET_TIMEOUT(client, env) \
                                 ((client)->ops->get_url(client, env))
+#define AXIS2_HTTP_CLIENT_SET_PROXY(client, env, proxy_host, proxy_port) \
+                                ((client)->ops->set_proxy(client, env,\
+								proxy_host, proxy_port))
+#define AXIS2_HTTP_CLIENT_GET_PROXY(client, env) \
+                                ((client)->ops->get_proxy(client, env))
 #define AXIS2_HTTP_CLIENT_FREE(client, env) \
                                 ((client)->ops->free(client, env))
 /************************** End of function macros ****************************/    

Modified: webservices/axis2/trunk/c/include/axis2_http_transport.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_http_transport.h?rev=407856&r1=407855&r2=407856&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_http_transport.h (original)
+++ webservices/axis2/trunk/c/include/axis2_http_transport.h Fri May 19 10:19:32 2006
@@ -372,6 +372,21 @@
      * Content type for MTOM
      */
     #define MTOM_RECIVED_CONTENT_TYPE "MTOM_RECEIVED"
+
+    /**
+     * Constant for HTTP proxy
+     */
+    #define AXIS2_HTTP_PROXY "PROXY"
+    
+    /**
+     * Constant for HTTP proxy host
+     */
+    #define AXIS2_PROXY_HOST_NAME "proxy_host"
+    
+    /**
+     * Constant for HTTP proxy port
+     */
+    #define AXIS2_PROXY_HOST_PORT "proxy_port"
     
 /** @} */
     

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c?rev=407856&r1=407855&r2=407856&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c Fri May 19 10:19:32 2006
@@ -45,6 +45,10 @@
 	axis2_http_simple_response_t *response;
 	axis2_bool_t request_sent;
 	int timeout;
+    axis2_bool_t proxy_enabled;
+    axis2_char_t *proxy_host;
+    int proxy_port;
+    axis2_char_t *proxy_host_port;
 };
 
 #define AXIS2_INTF_TO_IMPL(http_client) \
@@ -75,6 +79,17 @@
 axis2_http_client_get_timeout (axis2_http_client_t *client, axis2_env_t **env);
 
 axis2_status_t AXIS2_CALL 
+axis2_http_client_set_proxy(axis2_http_client_t *client, axis2_env_t **env, 
+                        axis2_char_t *proxy_host, int proxy_port);
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_client_get_proxy(axis2_http_client_t *client, axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_client_connect_ssl_host(axis2_http_client_t *client, 
+                        axis2_env_t **env, axis2_char_t *host, int port);
+
+axis2_status_t AXIS2_CALL 
 axis2_http_client_free (axis2_http_client_t *client, axis2_env_t **env);
 
 axis2_status_t AXIS2_CALL
@@ -103,6 +118,10 @@
 	http_client_impl->response = NULL;
 	http_client_impl->request_sent = AXIS2_FALSE;
 	http_client_impl->timeout = AXIS2_HTTP_DEFAULT_CONNECTION_TIMEOUT;
+    http_client_impl->proxy_enabled = AXIS2_FALSE;
+    http_client_impl->proxy_port = 0;
+    http_client_impl->proxy_host = NULL;
+    http_client_impl->proxy_host_port = NULL;
 	
     http_client_impl->http_client.ops = AXIS2_MALLOC((*env)->allocator,
 						sizeof(axis2_http_client_ops_t));
@@ -124,6 +143,10 @@
 						axis2_http_client_set_timeout;
 	http_client_impl->http_client.ops->get_timeout = 
 						axis2_http_client_get_timeout;
+    http_client_impl->http_client.ops->set_proxy = 
+                        axis2_http_client_set_proxy;
+    http_client_impl->http_client.ops->get_proxy = 
+                        axis2_http_client_get_proxy;
     http_client_impl->http_client.ops->free = axis2_http_client_free;
                         
 	return &(http_client_impl->http_client);
@@ -193,10 +216,21 @@
 		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NULL_URL, AXIS2_FAILURE);
 		return AXIS2_FAILURE;
 	}
-    
-	client_impl->sockfd = axis2_network_handler_open_socket(env, 
+    if(AXIS2_TRUE == client_impl->proxy_enabled)
+    {
+        if(NULL == client_impl->proxy_host || client_impl->proxy_port <= 0)
+        {
+            return AXIS2_FAILURE;
+        }
+	    client_impl->sockfd = axis2_network_handler_open_socket(env, 
+						client_impl->proxy_host, client_impl->proxy_port);
+    }
+    else
+    {
+        client_impl->sockfd = axis2_network_handler_open_socket(env, 
 						AXIS2_URL_GET_SERVER(client_impl->url, env), 
 						AXIS2_URL_GET_PORT(client_impl->url, env));
+    }
 	if(client_impl->sockfd < 0)
 	{
 		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
@@ -217,6 +251,15 @@
                         "HTTPS"))
     {
 #ifdef AXIS2_SSL_ENABLED
+        if(AXIS2_TRUE == client_impl->proxy_enabled) 
+        {
+            if(AXIS2_SUCCESS != axis2_http_client_connect_ssl_host(client, env, 
+                        AXIS2_URL_GET_SERVER(client_impl->url, env), 
+                        AXIS2_URL_GET_PORT(client_impl->url, env)))
+            {
+                return AXIS2_FAILURE;
+            }
+        }
         client_impl->data_stream = axis2_stream_create_ssl(env, 
                         client_impl->sockfd);
 #else
@@ -271,9 +314,44 @@
 			str_header = str_header2;
 		}
 	}
-	str_request_line = AXIS2_HTTP_REQUEST_LINE_TO_STRING(
+    if(AXIS2_FALSE == client_impl->proxy_enabled)
+    {
+        str_request_line = AXIS2_HTTP_REQUEST_LINE_TO_STRING(
 						AXIS2_HTTP_SIMPLE_REQUEST_GET_REQUEST_LINE(request, env)
 						, env);
+    }
+    else
+    {
+        /* we need the request line in the format
+         * POST http://host:port/path HTTP/1.x if we have enabled proxies
+         */
+        axis2_char_t *host_port_str = NULL;
+        axis2_char_t *server = AXIS2_URL_GET_SERVER(client_impl->url, env);
+        axis2_http_request_line_t *request_line = 
+                        AXIS2_HTTP_SIMPLE_REQUEST_GET_REQUEST_LINE(request, env);
+        axis2_char_t *path = AXIS2_HTTP_REQUEST_LINE_GET_URI(request_line, env);
+                
+        
+        /* length = len(server) + len(:port) + len("http://") + len(path) + 1*/
+        host_port_str = AXIS2_MALLOC((*env)->allocator, AXIS2_STRLEN(server) +
+                        + AXIS2_STRLEN(path) +  20 * sizeof(axis2_char_t));
+        if(NULL == host_port_str)
+        {
+            AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+            return AXIS2_FAILURE;
+        }
+        sprintf(host_port_str, "http://%s:%d%s", server, AXIS2_URL_GET_PORT(
+                        client_impl->url, env), path);
+        str_request_line = AXIS2_MALLOC((*env)->allocator, 
+                        AXIS2_STRLEN(host_port_str) + 20 * sizeof(axis2_char_t));
+        sprintf(str_request_line, "%s %s %s\r\n", 
+                        AXIS2_HTTP_REQUEST_LINE_GET_METHOD(request_line, env), 
+                        host_port_str, AXIS2_HTTP_REQUEST_LINE_GET_HTTP_VERSION(
+                        request_line, env));
+        AXIS2_FREE((*env)->allocator, host_port_str);
+        host_port_str = NULL;
+         
+    }
 	wire_format = AXIS2_STRACAT(str_request_line, str_header, env);
 	AXIS2_FREE((*env)->allocator, str_header);
 	str_header = NULL;
@@ -349,9 +427,9 @@
 	int status_code = -1;
 	axis2_http_client_impl_t *client_impl = NULL;
 	axis2_http_status_line_t *status_line = NULL;
-	char str_status_line[512];
-	char tmp_buf[3];
-	char str_header[512];
+	axis2_char_t str_status_line[512];
+	axis2_char_t tmp_buf[3];
+	axis2_char_t str_header[512];
 	int read = 0;
 	int http_status = 0;
 	axis2_bool_t end_of_line = AXIS2_FALSE;
@@ -514,4 +592,139 @@
 {
     AXIS2_ENV_CHECK(env, AXIS2_CRTICAL_FAILURE);
     return AXIS2_INTF_TO_IMPL(client)->timeout;
+}
+
+axis2_status_t AXIS2_CALL 
+axis2_http_client_set_proxy(axis2_http_client_t *client, axis2_env_t **env, 
+                        axis2_char_t *proxy_host, int proxy_port)
+{
+    axis2_http_client_impl_t *client_impl = NULL;
+    
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, proxy_host, AXIS2_FAILURE);
+    if(proxy_port <= 0)
+    {
+        return AXIS2_FAILURE;
+    }
+    client_impl = AXIS2_INTF_TO_IMPL(client);
+    client_impl->proxy_port = proxy_port;
+    if(NULL != client_impl->proxy_host)
+    {
+        AXIS2_FREE((*env)->allocator, client_impl->proxy_host);
+        client_impl->proxy_host = NULL;
+    }
+    if(NULL != client_impl->proxy_host_port)
+    {
+        AXIS2_FREE((*env)->allocator, client_impl->proxy_host_port);
+        client_impl->proxy_host_port = NULL;
+    }
+    client_impl->proxy_host = AXIS2_STRDUP(proxy_host, env);
+    if(NULL == client_impl->proxy_host)
+    {
+        return AXIS2_FAILURE;
+    }
+    client_impl->proxy_host_port = AXIS2_MALLOC((*env)->allocator, AXIS2_STRLEN(
+                            proxy_host) + 10 * sizeof(axis2_char_t));
+    sprintf(client_impl->proxy_host_port, "%s:%d", proxy_host, proxy_port);
+    client_impl->proxy_enabled = AXIS2_TRUE;
+    return AXIS2_SUCCESS;
+}
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_client_get_proxy(axis2_http_client_t *client, axis2_env_t **env)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+    return AXIS2_INTF_TO_IMPL(client)->proxy_host_port;
+}
+
+axis2_status_t AXIS2_CALL 
+axis2_http_client_connect_ssl_host(axis2_http_client_t *client, 
+                        axis2_env_t **env, axis2_char_t *host, int port)
+{
+    axis2_stream_t *tmp_stream = NULL;
+    axis2_char_t *connect_string = NULL;
+    axis2_char_t str_status_line[512];
+    axis2_char_t tmp_buf[3];
+    int read = 0;
+    axis2_bool_t end_of_line = AXIS2_FALSE;
+    axis2_bool_t end_of_response = AXIS2_FALSE;
+    axis2_http_client_impl_t *client_impl = NULL;
+    axis2_http_status_line_t *status_line = NULL;
+    
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, host, AXIS2_FAILURE);
+    
+    client_impl = AXIS2_INTF_TO_IMPL(client);
+    if(port <= 0)
+    {
+        return AXIS2_FAILURE;
+    }
+    
+    tmp_stream = axis2_stream_create_socket(env, client_impl->sockfd);
+    if(NULL == tmp_stream)
+    {
+        return AXIS2_FAILURE;
+    }
+    connect_string = AXIS2_MALLOC((*env)->allocator, 
+                        AXIS2_STRLEN(host) * sizeof(axis2_char_t) +
+                        30 * sizeof(axis2_char_t));
+    sprintf(connect_string, "CONNECT %s:%d HTTP/1.0\r\n\r\n", host, port);
+    AXIS2_STREAM_WRITE(tmp_stream, env, connect_string, 
+                    AXIS2_STRLEN(connect_string) * sizeof(axis2_char_t));
+    
+    memset(str_status_line, 0, 512);
+    while((read = AXIS2_STREAM_READ(tmp_stream, env, tmp_buf, 1)) > 0)
+    {
+        tmp_buf[read] = '\0';
+        strcat(str_status_line, tmp_buf);
+        if(0 != strstr(str_status_line, AXIS2_HTTP_CRLF))
+        {
+            end_of_line = AXIS2_TRUE;
+            break;
+        }
+    }
+    if (read < 0)
+    {
+        AXIS2_ERROR_SET((*env)->error, 
+                        AXIS2_ERROR_RESPONSE_TIMED_OUT, 
+                        AXIS2_FAILURE);
+        return AXIS2_FAILURE;
+    }
+    status_line = axis2_http_status_line_create(env, str_status_line);
+    if(NULL == status_line)
+    {
+        AXIS2_ERROR_SET((*env)->error, 
+                        AXIS2_ERROR_INVALID_HTTP_HEADER_START_LINE, 
+                        AXIS2_FAILURE);
+        return AXIS2_FAILURE;
+    }
+    if(200 != AXIS2_HTTP_STATUS_LINE_GET_STATUS_CODE(status_line, env))
+    {
+        return AXIS2_FAILURE;
+    }
+    /* We need to empty the stream before we return
+     */
+    memset(str_status_line, 0, 512);
+    while (AXIS2_FALSE == end_of_response)
+    {
+        while((read = AXIS2_STREAM_READ(tmp_stream, env, tmp_buf, 1)) > 0)
+        {
+            tmp_buf[read] = '\0';
+            strcat(str_status_line, tmp_buf);
+            if(0 != strstr(str_status_line, AXIS2_HTTP_CRLF))
+            {
+                end_of_line = AXIS2_TRUE;
+                break;
+            }
+        }
+        if(AXIS2_TRUE == end_of_line)
+        {
+            if(0 == AXIS2_STRCMP(str_status_line, AXIS2_HTTP_CRLF))
+            {
+                end_of_response = AXIS2_TRUE;
+            }
+        }
+    }
+    AXIS2_STREAM_FREE(tmp_stream, env);
+    return AXIS2_SUCCESS;
 }

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c?rev=407856&r1=407855&r2=407856&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c Fri May 19 10:19:32 2006
@@ -271,9 +271,17 @@
 	if(0 == AXIS2_STRCMP(sender_impl->http_version, 
 		AXIS2_HTTP_HEADER_PROTOCOL_11))
 	{
+		axis2_char_t *header = NULL;
+        header = AXIS2_MALLOC((*env)->allocator, AXIS2_STRLEN(
+                        AXIS2_URL_GET_SERVER(url, env)) + 10 * sizeof(
+                        axis2_char_t));
+        sprintf(header, "%s:%d", AXIS2_URL_GET_SERVER(url, env), 
+                        AXIS2_URL_GET_PORT(url, env));
 		http_header = axis2_http_header_create(env, 
 						AXIS2_HTTP_HEADER_HOST, 
-						AXIS2_URL_GET_SERVER(url, env));
+						header);
+        AXIS2_FREE((*env)->allocator, header);
+        header = NULL;
 		AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, env, http_header);
 	}
 	AXIS2_HTTP_SIMPLE_REQUEST_SET_BODY_STRING(request, env, buffer);

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c?rev=407856&r1=407855&r2=407856&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c Fri May 19 10:19:32 2006
@@ -25,6 +25,7 @@
 #include <axis2_xml_writer.h>
 #include <axis2_property.h>
 #include <axis2_types.h>
+#include <axis2_generic_obj.h>
 
 /** 
  * @brief SOAP over HTTP sender struct impl
@@ -86,6 +87,12 @@
 axis2_soap_over_http_sender_set_http_version
 									(axis2_soap_over_http_sender_t *sender, 
 									axis2_env_t **env, axis2_char_t *version);
+                                    
+axis2_status_t AXIS2_CALL
+axis2_soap_over_http_sender_configure_proxy(
+                                    axis2_soap_over_http_sender_t *sender, 
+									axis2_env_t **env, 
+                                    axis2_msg_ctx_t *msg_ctx);
 
 axis2_status_t AXIS2_CALL 
 axis2_soap_over_http_sender_free
@@ -214,6 +221,9 @@
 	{
 		return AXIS2_FAILURE;
 	}
+    /* configure proxy settings if we have set so 
+     */
+    axis2_soap_over_http_sender_configure_proxy(sender, env, msg_ctx);
     /* We put the client into msg_ctx so that we can free it once the processing
      * is done at client side
      */
@@ -357,9 +367,17 @@
 	if(0 == AXIS2_STRCMP(sender_impl->http_version, 
 		AXIS2_HTTP_HEADER_PROTOCOL_11))
 	{
+        axis2_char_t *header = NULL;
+        header = AXIS2_MALLOC((*env)->allocator, AXIS2_STRLEN(
+                        AXIS2_URL_GET_SERVER(url, env)) + 10 * sizeof(
+                        axis2_char_t));
+        sprintf(header, "%s:%d", AXIS2_URL_GET_SERVER(url, env), 
+                        AXIS2_URL_GET_PORT(url, env));
 		http_header = axis2_http_header_create(env, 
 						AXIS2_HTTP_HEADER_HOST, 
-						AXIS2_URL_GET_SERVER(url, env));
+						header);
+        AXIS2_FREE((*env)->allocator, header);
+        header = NULL;
 		AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, env, http_header);
 	}
 
@@ -631,4 +649,97 @@
 		return AXIS2_FAILURE;
 	}
 	return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_soap_over_http_sender_configure_proxy(axis2_soap_over_http_sender_t *sender, 
+									axis2_env_t **env, axis2_msg_ctx_t *msg_ctx)
+{
+    axis2_conf_ctx_t *conf_ctx = NULL;
+    axis2_conf_t *conf = NULL;
+    axis2_transport_out_desc_t *trans_desc = NULL;
+    axis2_param_t *proxy_param = NULL;
+    axis2_qname_t *transport_qname = NULL;
+    axis2_hash_t *transport_attrs = NULL;
+    axis2_soap_over_http_sender_impl_t *sender_impl = NULL;
+    
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, msg_ctx, AXIS2_FAILURE);
+    
+    sender_impl = AXIS2_INTF_TO_IMPL(sender);
+    conf_ctx = AXIS2_MSG_CTX_GET_CONF_CTX(msg_ctx, env);
+    if(NULL == conf_ctx)
+    {
+        return AXIS2_FAILURE;
+    }
+    conf = AXIS2_CONF_CTX_GET_CONF(conf_ctx, env);
+    if(NULL == conf)
+    {
+        return AXIS2_FAILURE;
+    }
+    transport_qname = axis2_qname_create(env, "http", NULL, NULL);
+    if(transport_qname == NULL)
+    {
+        return AXIS2_FAILURE;
+    }
+    trans_desc = AXIS2_CONF_GET_TRANSPORT_OUT(conf, env, transport_qname);
+    if(NULL == trans_desc)
+    {
+        return AXIS2_FAILURE;
+    }
+    proxy_param = AXIS2_PARAM_CONTAINER_GET_PARAM(trans_desc->param_container, 
+                            env, AXIS2_HTTP_PROXY);
+    if(NULL != proxy_param)
+    {
+        transport_attrs = AXIS2_PARAM_GET_ATTRIBUTES(proxy_param, env);
+        if(NULL != transport_attrs)
+        {
+            axis2_generic_obj_t *obj = NULL;
+            axis2_om_attribute_t *host_attr = NULL;
+            axis2_om_attribute_t *port_attr = NULL;
+            axis2_char_t *proxy_host = NULL;
+            axis2_char_t *proxy_port = NULL;
+            
+            obj = axis2_hash_get(transport_attrs, AXIS2_PROXY_HOST_NAME,
+                        AXIS2_HASH_KEY_STRING);
+            if(NULL == obj)
+            {
+                return AXIS2_FAILURE;
+            }
+            host_attr = (axis2_om_attribute_t*)AXIS2_GENERIC_OBJ_GET_VALUE(obj,
+                        env);
+            if(NULL == host_attr)
+            {
+                return AXIS2_FAILURE;
+            }
+            proxy_host = AXIS2_OM_ATTRIBUTE_GET_VALUE(host_attr, env);
+            if(NULL == proxy_host)
+            {
+                return AXIS2_FAILURE;
+            }
+            /* Now we get the port */
+            obj = NULL;
+            
+            obj = axis2_hash_get(transport_attrs, AXIS2_PROXY_HOST_PORT,
+                        AXIS2_HASH_KEY_STRING);
+            port_attr = (axis2_om_attribute_t*)AXIS2_GENERIC_OBJ_GET_VALUE(obj,
+                        env);
+            if(NULL == port_attr)
+            {
+                return AXIS2_FAILURE;
+            }
+            proxy_port = AXIS2_OM_ATTRIBUTE_GET_VALUE(port_attr, env);
+            if(NULL == proxy_port)
+            {
+                return AXIS2_FAILURE;
+            }
+            if(NULL != proxy_host && NULL != proxy_port)
+            {
+                AXIS2_HTTP_CLIENT_SET_PROXY(sender_impl->client, env, proxy_host,
+                        AXIS2_ATOI(proxy_port));
+                return AXIS2_SUCCESS;
+            }
+        }
+    }
+    return AXIS2_SUCCESS;
 }

Modified: webservices/axis2/trunk/c/test/core/transport/http/test_http_transport.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/test/core/transport/http/test_http_transport.c?rev=407856&r1=407855&r2=407856&view=diff
==============================================================================
--- webservices/axis2/trunk/c/test/core/transport/http/test_http_transport.c (original)
+++ webservices/axis2/trunk/c/test/core/transport/http/test_http_transport.c Fri May 19 10:19:32 2006
@@ -126,7 +126,7 @@
     request_body = axis2_stream_create_basic(&env);
     request = axis2_http_simple_request_create(&env, request_line,
                         NULL, 0, NULL);
-    url = axis2_url_create(&env, "http", "localhost", 9090,
+    url = axis2_url_create(&env, "http", "localhost", 80,
                         NULL);
     header = axis2_http_header_create(&env,"Host", AXIS2_URL_GET_SERVER(url, &env));
     AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, &env, header);
@@ -164,6 +164,73 @@
     AXIS2_FREE(env->allocator, body_bytes);
     printf("Finished http_client tests ..........\n\n");
 }
+
+void test_https_client(axis2_env_t *env)
+{
+#ifndef AXIS2_SSL_ENABLED
+    return;
+#else
+    axis2_http_client_t *client = NULL;
+    axis2_http_simple_request_t *request = NULL;
+    axis2_http_request_line_t *request_line = NULL;
+    axis2_url_t *url = NULL;
+    axis2_http_header_t *header = NULL;
+    axis2_stream_t *request_body = NULL;
+    axis2_http_simple_response_t *response = NULL;
+    int status = 0;
+    char *body_bytes = NULL;
+    int body_bytes_len = 0;
+
+    printf("Starting https_client tests\n");
+    request_line = axis2_http_request_line_create(&env, "GET", 
+                        "/", "HTTP/1.0");
+    request_body = axis2_stream_create_basic(&env);
+    request = axis2_http_simple_request_create(&env, request_line,
+                        NULL, 0, NULL);
+    url = axis2_url_create(&env, "https", "localhost", 443,
+                        NULL);
+    /* Add an ssl certificate variable */
+    setenv("AXIS2_SSL_CA_FILE", "cert.pem", 1); 
+    header = axis2_http_header_create(&env,"Host", AXIS2_URL_GET_SERVER(url, &env));
+    AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, &env, header);
+    client = axis2_http_client_create(&env, url); 
+    
+    /* if you weant to test the proxy uncomment following */
+    AXIS2_HTTP_CLIENT_SET_PROXY(client, &env, "127.0.0.1", 8080); 
+    
+    status = AXIS2_HTTP_CLIENT_SEND(client, &env, request);
+    if(status < 0)
+    {
+        printf("Test FAILED .........Can't send the request. Status :%d\n", status);
+        return;
+    }
+    status = AXIS2_HTTP_CLIENT_RECIEVE_HEADER(client, &env);
+    if(status < 0)
+    {
+        printf("Test FAILED ......... Can't recieve. Status: %d\n", status);
+        return;
+    }
+    response = AXIS2_HTTP_CLIENT_GET_RESPONSE(client, &env);
+    if(NULL == response)
+    {
+        printf("Test Failed : NULL response");
+        return;
+    }
+    printf("Content Type :%s\n", AXIS2_HTTP_SIMPLE_RESPONSE_GET_CONTENT_TYPE(
+                        response, &env));
+    printf("Content Length :%d\n", AXIS2_HTTP_SIMPLE_RESPONSE_GET_CONTENT_LENGTH(
+                        response, &env));
+    printf("Status code :%d\n", status);
+    body_bytes_len = AXIS2_HTTP_SIMPLE_RESPONSE_GET_BODY_BYTES(response, &env, &body_bytes);
+   
+    AXIS2_HTTP_CLIENT_FREE(client, &env); 
+    AXIS2_HTTP_SIMPLE_REQUEST_FREE(request, &env);
+    AXIS2_STREAM_FREE(request_body, &env);
+    AXIS2_FREE(env->allocator, body_bytes);
+    printf("Finished https_client tests ..........\n\n");
+#endif
+}
+
 int main(void)
 {
 	axis2_env_t *env = test_init();
@@ -171,6 +238,7 @@
     test_http_status_line(env);
     test_http_header(env);
     test_http_client(env);
+    test_https_client(env);
     test_url(env);
     
     axis2_allocator_t *allocator = env->allocator;



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org