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 da...@apache.org on 2008/07/01 08:29:51 UTC

svn commit: r673007 - in /webservices/axis2/trunk/c/src/core/transport/http/sender: http_client.c http_sender.c

Author: damitha
Date: Mon Jun 30 23:29:50 2008
New Revision: 673007

URL: http://svn.apache.org/viewvc?rev=673007&view=rev
Log:
Some code formatting

Modified:
    webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c
    webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c

Modified: webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c?rev=673007&r1=673006&r2=673007&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c Mon Jun 30 23:29:50 2008
@@ -148,9 +148,8 @@
 
     if (!client->req_body)
     {
-        client->req_body_size =
-            axis2_http_simple_request_get_body_bytes(request, env,
-                                                     &client->req_body);
+        client->req_body_size = axis2_http_simple_request_get_body_bytes(request, env, 
+                &client->req_body);
     }
 
     if (client->dump_input_msg == AXIS2_TRUE)
@@ -169,23 +168,22 @@
     port = axutil_url_get_port(client->url, env);
 
 
-    if (AXIS2_TRUE == client->proxy_enabled)
+    if (client->proxy_enabled)
     {
         if (!client->proxy_host || client->proxy_port <= 0)
         {
             AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Proxy port or Host not set");
             return AXIS2_FAILURE;
         }
-        client->sockfd = (int)axutil_network_handler_open_socket(env,
-                                                            client->proxy_host,
-                                                            client->proxy_port);
+
+        client->sockfd = (int)axutil_network_handler_open_socket(env, client->proxy_host, 
+            client->proxy_port);
     }
     else
     {
         /*Proxy is not enabled*/
 
-        client->sockfd = 
-            (int)axutil_network_handler_open_socket(env, host, port);
+        client->sockfd = (int)axutil_network_handler_open_socket(env, host, port);
     }
 
     if (client->sockfd < 0)
@@ -198,39 +196,31 @@
     if (client->timeout > 0)
     {
         /*Set the receiving time out*/
-        axutil_network_handler_set_sock_option(env, client->sockfd,
-                                               SO_RCVTIMEO, client->timeout);
+        axutil_network_handler_set_sock_option(env, client->sockfd, SO_RCVTIMEO, client->timeout);
         /*Set the sending time out*/
 
-        axutil_network_handler_set_sock_option(env, client->sockfd,
-                                               SO_SNDTIMEO, client->timeout);
+        axutil_network_handler_set_sock_option(env, client->sockfd, SO_SNDTIMEO, client->timeout);
     }
 
-    if (0 == axutil_strcasecmp(axutil_url_get_protocol(client->url, env),
-                               AXIS2_TRANSPORT_URL_HTTPS))
+    if (0 == axutil_strcasecmp(axutil_url_get_protocol(client->url, env), AXIS2_TRANSPORT_URL_HTTPS))
     {
 #ifdef AXIS2_SSL_ENABLED
-        if (AXIS2_TRUE == client->proxy_enabled)
+        if (client->proxy_enabled)
         {
-            if (AXIS2_SUCCESS !=
-                axis2_http_client_connect_ssl_host(client, env, host, port));
+            if (AXIS2_SUCCESS != axis2_http_client_connect_ssl_host(client, env, host, port));
             {
                 AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "HTTPS connection creation failed");
                 return AXIS2_FAILURE;
             }
         }
         client->data_stream =
-            axutil_stream_create_ssl(env,
-                                     client->sockfd,
-                                     axis2_http_client_get_server_cert
-                                     (client, env),
-                                     axis2_http_client_get_key_file
-                                     (client, env), ssl_pp);
+            axutil_stream_create_ssl(env, client->sockfd, axis2_http_client_get_server_cert(client, 
+                        env), axis2_http_client_get_key_file(client, env), ssl_pp);
 #else
-        AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_TRANSPORT_PROTOCOL,
-                        AXIS2_FAILURE);
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid Transport Protocol,\
-            HTTPS transport not enabled.");
+        AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_TRANSPORT_PROTOCOL, AXIS2_FAILURE);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+                "Invalid Transport Protocol, HTTPS transport not enabled.");
+
         return AXIS2_FAILURE;
 #endif
     }
@@ -242,8 +232,9 @@
     if (!client->data_stream)
     {
         axutil_network_handler_close_socket(env, client->sockfd);
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Data stream creation failed \
-        for Host %s and %d port", host, port);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+                "Data stream creation failed for Host %s and %d port", host, port);
+
         return AXIS2_FAILURE;
     }
 
@@ -258,8 +249,9 @@
         for (i = 0; i < header_count; i++)
         {
             axis2_char_t *header_ext_form = NULL;
-            axis2_http_header_t *tmp_header = (axis2_http_header_t *)
-                axutil_array_list_get(headers, env, i);
+            axis2_http_header_t *tmp_header = (axis2_http_header_t *) axutil_array_list_get(headers, 
+                    env, i);
+
             if (!tmp_header)
             {
                 /* This continue is added as a safey mechanism,
@@ -275,16 +267,15 @@
 
             /* check whether we have transfer encoding and then see whether the
              * value is "chunked" */
-            if (0 == axutil_strcmp(axis2_http_header_get_name(tmp_header, env),
-                                   AXIS2_HTTP_HEADER_TRANSFER_ENCODING) && 0 ==
-                axutil_strcmp(axis2_http_header_get_value(tmp_header,
-                                                          env),
-                              AXIS2_HTTP_HEADER_TRANSFER_ENCODING_CHUNKED))
+            if (!axutil_strcmp(axis2_http_header_get_name(tmp_header, env), 
+                    AXIS2_HTTP_HEADER_TRANSFER_ENCODING) && 
+                    !axutil_strcmp(axis2_http_header_get_value(tmp_header, env), 
+                        AXIS2_HTTP_HEADER_TRANSFER_ENCODING_CHUNKED))
             {
                 chunking_enabled = AXIS2_TRUE;
             }
-            header_ext_form =
-                axis2_http_header_to_external_form(tmp_header, env);
+
+            header_ext_form = axis2_http_header_to_external_form(tmp_header, env);
 
             /* str_header2 is to hold intermediate value of str_header */
             str_header2 = axutil_stracat(env, str_header, header_ext_form);
@@ -300,8 +291,7 @@
 
     if (AXIS2_FALSE == client->proxy_enabled)
     {
-        str_request_line =
-            axis2_http_request_line_to_string
+        str_request_line = axis2_http_request_line_to_string
             (axis2_http_simple_request_get_request_line(request, env), env);
     }
     else
@@ -317,61 +307,57 @@
             axis2_http_simple_request_get_request_line(request, env);
         axis2_char_t *path = axis2_http_request_line_get_uri(request_line, env);
 
-        host_port_str = AXIS2_MALLOC(env->allocator, axutil_strlen(host) +
-                                     +axutil_strlen(path) +
-                                     20 * sizeof(axis2_char_t));
+        host_port_str = AXIS2_MALLOC(env->allocator, axutil_strlen(host) + axutil_strlen(path) +
+            20 * sizeof(axis2_char_t));
+
         if (!host_port_str)
         {
             AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-            AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "memory allocation failed\
- for host %s and %s path", host, path);
+            AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, 
+                    "Memory allocation failed for host %s and %s path", host, path);
+
             return AXIS2_FAILURE;
         }
 
-        sprintf(host_port_str, "http://%s:%d%s", host,
-                axutil_url_get_port(client->url, env), path);
-        str_request_line =
-            AXIS2_MALLOC(env->allocator,
-                         axutil_strlen(host_port_str) +
+        sprintf(host_port_str, "http://%s:%d%s", host, axutil_url_get_port(client->url, env), path);
+        str_request_line = AXIS2_MALLOC(env->allocator, axutil_strlen(host_port_str) +
                          20 * sizeof(axis2_char_t));
 
         if (!str_request_line)
         {
             AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-            AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "memory allocation failed\
- for host %s and %s path", host, path);
+            AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, 
+                    "memory allocation failed for host %s and %s path", host, path);
+
             return AXIS2_FAILURE;
         }
 
-        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));
+        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 = axutil_stracat(env, str_request_line, str_header);
     AXIS2_FREE(env->allocator, str_header);
     str_header = NULL;
     AXIS2_FREE(env->allocator, str_request_line);
     str_request_line = NULL;
-    written = axutil_stream_write(client->data_stream, env, wire_format,
-                                  axutil_strlen(wire_format));
+    written = axutil_stream_write(client->data_stream, env, wire_format, axutil_strlen(wire_format));
     AXIS2_FREE(env->allocator, wire_format);
     wire_format = NULL;
     written = axutil_stream_write(client->data_stream, env, AXIS2_HTTP_CRLF, 2);
     if (client->req_body_size > 0 && client->req_body)
     {
-        if (AXIS2_FALSE == chunking_enabled)
+        if (!chunking_enabled)
         {
             status = AXIS2_SUCCESS;
             while (written < client->req_body_size)
             {
-                written = axutil_stream_write(client->data_stream, env,
-                                              client->req_body,
-                                              client->req_body_size);
+                written = axutil_stream_write(client->data_stream, env, client->req_body, 
+                    client->req_body_size);
                 if (-1 == written)
                 {
                     status = AXIS2_FAILURE;
@@ -384,9 +370,7 @@
 
             /* Sending HTTP request via chunking */
             axutil_http_chunked_stream_t *chunked_stream = NULL;
-            chunked_stream = axutil_http_chunked_stream_create(env,
-                                                              client->
-                                                              data_stream);
+            chunked_stream = axutil_http_chunked_stream_create(env, client->data_stream);
             status = AXIS2_SUCCESS;
             if (!chunked_stream)
             {
@@ -396,20 +380,21 @@
 
             while (written < client->req_body_size)
             {
-                written = axutil_http_chunked_stream_write(chunked_stream, env,
-                                                          client->req_body,
-                                                          client->
-                                                          req_body_size);
+                written = axutil_http_chunked_stream_write(chunked_stream, env, client->req_body, 
+                        client->req_body_size);
+
                 if (-1 == written)
                 {
                     status = AXIS2_FAILURE;
                     break;
                 }
             }
+
             if (AXIS2_SUCCESS == status)
             {
                 axutil_http_chunked_stream_write_last_chunk(chunked_stream, env);
             }
+
             axutil_http_chunked_stream_free(chunked_stream, env);
         }
     }

Modified: webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c?rev=673007&r1=673006&r2=673007&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c Mon Jun 30 23:29:50 2008
@@ -1370,17 +1370,13 @@
         op = axis2_msg_ctx_get_op (msg_ctx, env);
         if (op)
         {
-            const axis2_char_t *mep =
-                axis2_op_get_msg_exchange_pattern (op, env);
-            AXIS2_HANDLE_ERROR(env,
-                               AXIS2_ERROR_HTTP_CLIENT_TRANSPORT_ERROR,
-                               AXIS2_FAILURE);
+            const axis2_char_t *mep = axis2_op_get_msg_exchange_pattern (op, env);
+            AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_HTTP_CLIENT_TRANSPORT_ERROR, AXIS2_FAILURE);
             /* handle one way case */
 
-            if (axutil_strcmp (mep, AXIS2_MEP_URI_OUT_ONLY) == 0)
+            if (!axutil_strcmp (mep, AXIS2_MEP_URI_OUT_ONLY))
             {
-                AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
-                                 "mep is AXIS2_MEP_URI_OUT_ONLY");
+                AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "mep is AXIS2_MEP_URI_OUT_ONLY");
                 return AXIS2_FAILURE;
             }
         }