You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2007/02/26 05:32:09 UTC

svn commit: r511722 - in /webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http: sender/ sender/libcurl/ server/apache2/

Author: dinesh
Date: Sun Feb 25 20:32:08 2007
New Revision: 511722

URL: http://svn.apache.org/viewvc?view=rev&rev=511722
Log:
axis2c-532: transport sender refactoring and axis2c-487:libcurl base transport

Modified:
    webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/Makefile.am
    webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/http_sender.c
    webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/http_transport_sender.c
    webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/Makefile.am
    webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/Makefile.in
    webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/axis2_libcurl.c
    webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/server/apache2/apache2_worker.c

Modified: webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/Makefile.am?view=diff&rev=511722&r1=511721&r2=511722
==============================================================================
--- webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/Makefile.am (original)
+++ webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/Makefile.am Sun Feb 25 20:32:08 2007
@@ -12,7 +12,8 @@
 
 
 if AXIS2_LIBCURL_ENABLED
-libaxis2_http_sender_la_SOURCES +=libcurl/axis2_libcurl.c
+libaxis2_http_sender_la_SOURCES +=libcurl/axis2_libcurl.c\
+                                  libcurl/libcurl_stream.c
 
 libaxis2_http_sender_la_LIBADD +=-lssl\
                                   -lcrypto\

Modified: webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/http_sender.c
URL: http://svn.apache.org/viewvc/webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/http_sender.c?view=diff&rev=511722&r1=511721&r2=511722
==============================================================================
--- webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/http_sender.c (original)
+++ webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/http_sender.c Sun Feb 25 20:32:08 2007
@@ -440,7 +440,7 @@
     
 	if (AXIS2_TRUE == AXIS2_MSG_CTX_GET_IS_SOAP_11(msg_ctx, env))
     {
-        if ('\"' != *soap_action)
+       if ('\"' != *soap_action)
         {
             axis2_char_t *tmp_soap_action = NULL;
             tmp_soap_action = AXIS2_MALLOC(env->allocator, (

Modified: webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/http_transport_sender.c
URL: http://svn.apache.org/viewvc/webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/http_transport_sender.c?view=diff&rev=511722&r1=511721&r2=511722
==============================================================================
--- webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/http_transport_sender.c (original)
+++ webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/http_transport_sender.c Sun Feb 25 20:32:08 2007
@@ -603,7 +603,6 @@
 			AXIS2_MSG_CTX_SET_RESPONSE_SOAP_ENVELOPE (msg_ctx, env, response_envelope);
 		}
     }
-
     return status;
 }
 

Modified: webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/Makefile.am?view=diff&rev=511722&r1=511721&r2=511722
==============================================================================
--- webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/Makefile.am (original)
+++ webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/Makefile.am Sun Feb 25 20:32:08 2007
@@ -1,2 +1,2 @@
-EXTRA_DIST= axis2_libcurl.h axis2_libcurl.c
+EXTRA_DIST= axis2_libcurl.h axis2_libcurl.c libcurl_stream.h libcurl_stream.c
 

Modified: webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/Makefile.in
URL: http://svn.apache.org/viewvc/webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/Makefile.in?view=diff&rev=511722&r1=511721&r2=511722
==============================================================================
--- webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/Makefile.in (original)
+++ webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/Makefile.in Sun Feb 25 20:32:08 2007
@@ -172,7 +172,7 @@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
-EXTRA_DIST = axis2_libcurl.h axis2_libcurl.c
+EXTRA_DIST = axis2_libcurl.h axis2_libcurl.c libcurl_stream.h libcurl_stream.c
 all: all-am
 
 .SUFFIXES:

Modified: webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/axis2_libcurl.c
URL: http://svn.apache.org/viewvc/webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/axis2_libcurl.c?view=diff&rev=511722&r1=511721&r2=511722
==============================================================================
--- webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/axis2_libcurl.c (original)
+++ webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/axis2_libcurl.c Sun Feb 25 20:32:08 2007
@@ -16,6 +16,7 @@
 #include <axis2_util.h>
 #include <stdlib.h>
 #include <axis2_http_transport.h>
+#include <libcurl_stream.h>
 
 typedef struct axis2_libcurl
 {
@@ -25,8 +26,7 @@
 	const axis2_env_t *env;
 }axis2_libcurl_t;
 
-
-size_t
+size_t 
 axis2_libcurl_write_memory_callback(
 	void *ptr, 
 	size_t size, 
@@ -49,11 +49,6 @@
 	const axis2_env_t *env, 
 	axis2_libcurl_t *curl);
 
-int
-axis2_libcurl_process_headers (
-	const axis2_env_t *evn,
-	axis2_http_simple_response_t *response, 
-	axis2_array_list_t *alist);
 
 axis2_status_t AXIS2_CALL
 axis2_libcurl_send (
@@ -79,14 +74,24 @@
 	axis2_char_t *buffer = NULL;
 	unsigned int buffer_size = 0;
 	axis2_char_t *content_type;
+	axis2_char_t *content_len = "Content-Length:";
 	const axis2_char_t *char_set_enc = NULL;
 	axis2_char_t *content = "Content-Type:";
+	axis2_char_t *soap_action_header = "SOAPAction:";
 	axis2_libcurl_t *data;
 	axis2_libcurl_t *header;
+	axis2_stream_t *in_stream;
+	axis2_property_t *trans_in_property;
+	axis2_string_t *char_set_enc_str;
+    axis2_byte_t *output_stream = NULL;
+    int output_stream_size = 0;
+
 	data = axis2_libcurl_create (env);
 	header = axis2_libcurl_create (env);
 	handler = curl_easy_init ();
-	
+	headers = curl_slist_append (headers, "User-Agent:Axis2/C");
+	headers = curl_slist_append (headers, "Accept:");
+	headers = curl_slist_append (headers, "Expect:");
     if (AXIS2_TRUE == AXIS2_MSG_CTX_GET_DOING_REST(msg_ctx, env))
 		is_soap = AXIS2_FALSE;
 	else
@@ -127,15 +132,16 @@
 	{
 		xml_writer = AXIOM_OUTPUT_GET_XML_WRITER(om_output, env);
 
-		/* char_set_enc_str = axis2_msg_ctx_get_charset_encoding(msg_ctx, env); */
-/* 		if (!char_set_enc_str) */
-/* 		{ */
-		char_set_enc = AXIS2_DEFAULT_CHAR_SET_ENCODING;
-/* 		} */
-/* 		else */
-/* 		{ */
-/* 			char_set_enc = axis2_string_get_buffer(char_set_enc_str, env); */
-/* 		} */
+		char_set_enc_str = axis2_msg_ctx_get_charset_encoding(msg_ctx, env);
+
+		if (!char_set_enc_str)
+		{
+			char_set_enc = AXIS2_DEFAULT_CHAR_SET_ENCODING;
+		}
+		else
+		{
+			char_set_enc = axis2_string_get_buffer(char_set_enc_str, env);
+		}
 
 		if (is_soap)
 		{
@@ -145,9 +151,29 @@
 										 doing_mtom); 
 			AXIOM_SOAP_ENVELOPE_SERIALIZE(out, env, om_output,
 										  AXIS2_FALSE);
+			if (AXIS2_TRUE == AXIS2_MSG_CTX_GET_IS_SOAP_11(msg_ctx, env))
+			{
+				if ('\"' != *soap_action)
+				{
+					axis2_char_t *tmp_soap_action = NULL;
+					tmp_soap_action = AXIS2_MALLOC(env->allocator, (
+													   AXIS2_STRLEN(soap_action) + 5) * sizeof(axis2_char_t));
+					sprintf(tmp_soap_action, "\"%s\"", soap_action);
+					headers = curl_slist_append (headers, 
+												 AXIS2_STRACAT (soap_action_header, tmp_soap_action,env));
+					AXIS2_FREE(env->allocator, tmp_soap_action);
+				}
+				else
+				{
+					headers = curl_slist_append (headers, 
+												 AXIS2_STRACAT (soap_action_header, soap_action,env));
+				}
+			}
 
 			if (doing_mtom)
 			{
+				AXIOM_OUTPUT_FLUSH(om_output, env, &output_stream,
+								   &output_stream_size);
 				content_type = (axis2_char_t *)AXIOM_OUTPUT_GET_CONTENT_TYPE(om_output,
 																			 env);
 				if (AXIS2_TRUE != AXIS2_MSG_CTX_GET_IS_SOAP_11(msg_ctx, env))
@@ -195,7 +221,6 @@
 				AXIS2_FREE(env->allocator, content_type);
 				content_type = temp_content_type;
 			}
-
 		}
 		else
 		{
@@ -225,17 +250,31 @@
 		}
 
 		buffer = AXIOM_XML_WRITER_GET_XML(xml_writer, env);
-		buffer_size = AXIOM_XML_WRITER_GET_XML_SIZE(xml_writer, env);
+		if (!doing_mtom)
+		{
+			buffer_size = AXIOM_XML_WRITER_GET_XML_SIZE(xml_writer, env);
+		}
+		else
+			buffer_size = output_stream_size;
 	}
 
-
-	headers = curl_slist_append (headers, "User-Agent:Axis2/C");
+	char tmp_buf[10];
+	sprintf (tmp_buf, "%d", buffer_size);
+	headers = curl_slist_append (headers, AXIS2_STRACAT (content_len, tmp_buf, env));
 	headers = curl_slist_append (headers, AXIS2_STRACAT (content,content_type, env));
-	headers = curl_slist_append (headers, "Accept:");
 	curl_easy_setopt (handler, CURLOPT_URL, str_url);
 	curl_easy_setopt (handler, CURLOPT_HTTPHEADER, headers);
-	curl_easy_setopt (handler, CURLOPT_POSTFIELDS, buffer);
-	curl_easy_setopt (handler, CURLOPT_POSTFIELDSIZE, buffer_size);
+
+	if (!doing_mtom)
+	{
+		curl_easy_setopt (handler, CURLOPT_POSTFIELDSIZE, buffer_size);
+		curl_easy_setopt (handler, CURLOPT_POSTFIELDS, buffer);
+	}
+	else 
+	{
+		curl_easy_setopt (handler, CURLOPT_POSTFIELDSIZE, output_stream_size);
+		curl_easy_setopt (handler, CURLOPT_POSTFIELDS, output_stream);
+	}
 	curl_easy_setopt (handler, CURLOPT_WRITEFUNCTION, axis2_libcurl_write_memory_callback);
 	curl_easy_setopt (handler, CURLOPT_WRITEDATA, data);
 	curl_easy_setopt (handler, CURLOPT_HEADERFUNCTION, axis2_libcurl_header_callback);
@@ -243,6 +282,15 @@
 	curl_easy_perform (handler);
 	curl_slist_free_all (headers);
 	curl_easy_cleanup (handler);
+
+	in_stream = axis2_stream_create_libcurl (env, data->memory, data->size);
+
+    trans_in_property = axis2_property_create(env);
+    AXIS2_PROPERTY_SET_SCOPE(trans_in_property, env, AXIS2_SCOPE_REQUEST);
+    AXIS2_PROPERTY_SET_FREE_FUNC(trans_in_property, env, axis2_stream_free_void_arg);
+    AXIS2_PROPERTY_SET_VALUE(trans_in_property, env, in_stream);
+    AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, AXIS2_TRANSPORT_IN, trans_in_property,
+							   AXIS2_FALSE);
 	return AXIS2_SUCCESS;
 }
 
@@ -251,12 +299,16 @@
 {
 	size_t realsize = size * nmemb;
 	axis2_libcurl_t *mem = (axis2_libcurl_t *)data;
-	mem->memory = (axis2_char_t *) malloc (realsize + 1);
-	if (mem->memory) 
+	axis2_char_t *buffer = (axis2_char_t *) AXIS2_MALLOC (mem->env->allocator, mem->size + realsize + 1);
+	if (buffer) 
 	{
-		memcpy(&(mem->memory[mem->size]), ptr, realsize);
-		mem->size += realsize;
-		mem->memory[mem->size] = 0;
+
+		if (mem->size)
+			memcpy (&(buffer[0]), mem->memory, mem->size);
+			memcpy(&(buffer[mem->size]), ptr, realsize);
+			mem->size += realsize;
+			buffer[mem->size] = 0;
+			mem->memory = buffer;
 	}
 	return realsize;
 }
@@ -293,11 +345,4 @@
 axis2_libcurl_free (const axis2_env_t *env, axis2_libcurl_t *curl)
 {
 	AXIS2_FREE (env->allocator, curl);
-}
-
-int
-axis2_libcurl_process_headers (const axis2_env_t *env, axis2_http_simple_response_t *response, axis2_array_list_t *alist)
-{
-	int status_code = 0;
-	return status_code;
 }

Modified: webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/server/apache2/apache2_worker.c
URL: http://svn.apache.org/viewvc/webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/server/apache2/apache2_worker.c?view=diff&rev=511722&r1=511721&r2=511722
==============================================================================
--- webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/server/apache2/apache2_worker.c (original)
+++ webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/server/apache2/apache2_worker.c Sun Feb 25 20:32:08 2007
@@ -379,3 +379,10 @@
     return buffer;
 }
 
+
+
+
+
+
+
+



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