axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From din...@apache.org
Subject svn commit: r511774 - /webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/axis2_libcurl.c
Date Mon, 26 Feb 2007 10:38:50 GMT
Author: dinesh
Date: Mon Feb 26 02:38:50 2007
New Revision: 511774

URL: http://svn.apache.org/viewvc?view=rev&rev=511774
Log:
implement get method using libcurl

Modified:
    webservices/axis2/scratch/c/dinesh/532/c/modules/core/transport/http/sender/libcurl/axis2_libcurl.c

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=511774&r1=511773&r2=511774
==============================================================================
--- 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
Mon Feb 26 02:38:50 2007
@@ -49,6 +49,13 @@
 	const axis2_env_t *env, 
 	axis2_libcurl_t *curl);
 
+axis2_status_t AXIS2_CALL
+axis2_libcurl_get_param_string(
+    const axis2_env_t *env,
+    axis2_msg_ctx_t *msg_ctx,
+	CURL *handle);
+
+
 
 axis2_status_t AXIS2_CALL
 axis2_libcurl_send (
@@ -256,25 +263,36 @@
 		}
 		else
 			buffer_size = output_stream_size;
-	}
 
-	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));
-	curl_easy_setopt (handler, CURLOPT_URL, str_url);
-	curl_easy_setopt (handler, CURLOPT_HTTPHEADER, headers);
-
-	if (!doing_mtom)
-	{
-		curl_easy_setopt (handler, CURLOPT_POSTFIELDSIZE, buffer_size);
-		curl_easy_setopt (handler, CURLOPT_POSTFIELDS, buffer);
+		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));
+		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_URL, str_url);
 	}
-	else 
+	else
 	{
-		curl_easy_setopt (handler, CURLOPT_POSTFIELDSIZE, output_stream_size);
-		curl_easy_setopt (handler, CURLOPT_POSTFIELDS, output_stream);
+		axis2_char_t *request_param;
+		axis2_char_t *url_encode;
+		request_param = (axis2_char_t *) axis2_http_sender_get_param_string(env, NULL, msg_ctx);
+		url_encode = axis2_strcat(env, str_url, "?",
+								  request_param, NULL);
+		curl_easy_setopt (handler, CURLOPT_HTTPGET, 1);
+		curl_easy_setopt (handler, CURLOPT_URL, url_encode);
 	}
+
+	curl_easy_setopt (handler, CURLOPT_VERBOSE, 1);
+	curl_easy_setopt (handler, CURLOPT_HTTPHEADER, headers);
 	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);
@@ -284,7 +302,6 @@
 	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);
@@ -345,4 +362,53 @@
 axis2_libcurl_free (const axis2_env_t *env, axis2_libcurl_t *curl)
 {
 	AXIS2_FREE (env->allocator, curl);
+}
+
+axis2_status_t AXIS2_CALL
+axis2_libcurl_get_param_string(
+    const axis2_env_t *env,
+    axis2_msg_ctx_t *msg_ctx,
+	CURL *handle)
+{
+    axiom_soap_envelope_t *soap_env = NULL;
+    axiom_node_t *body_node = NULL;
+    axiom_node_t *data_node = NULL;
+    axiom_element_t *data_element = NULL;
+    axiom_child_element_iterator_t *iterator = NULL;
+    axis2_array_list_t *param_list = NULL;
+	struct curl_httppost *post=NULL;  
+	struct curl_httppost *last=NULL;  
+
+    AXIS2_ENV_CHECK(env, NULL);
+    
+    soap_env = AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(msg_ctx, env);
+    if (NULL == soap_env)
+    {
+        return AXIS2_FAILURE;
+    }
+    body_node = AXIOM_SOAP_BODY_GET_BASE_NODE(
+                AXIOM_SOAP_ENVELOPE_GET_BODY(soap_env, env), env);
+    data_node = AXIOM_NODE_GET_FIRST_CHILD(body_node, env);
+    if (NULL == data_node)
+    {
+		return AXIS2_FAILURE;
+    }
+    param_list = axis2_array_list_create(env, AXIS2_ARRAY_LIST_DEFAULT_CAPACITY);
+    data_element = AXIOM_NODE_GET_DATA_ELEMENT(data_node, env);
+    iterator = AXIOM_ELEMENT_GET_CHILD_ELEMENTS(data_element, env, data_node);
+    while (AXIS2_TRUE == AXIOM_CHILD_ELEMENT_ITERATOR_HAS_NEXT(iterator, env))
+    {
+        axiom_node_t *node = NULL;
+        axiom_element_t *element = NULL;
+        axis2_char_t *name = NULL;
+        axis2_char_t *value = NULL;
+        node = AXIOM_CHILD_ELEMENT_ITERATOR_NEXT(iterator, env);
+        element = AXIOM_NODE_GET_DATA_ELEMENT(node, env);
+        name = AXIOM_ELEMENT_GET_LOCALNAME(element, env);
+        value = AXIOM_ELEMENT_GET_TEXT(element, env, node);
+		curl_formadd(&post, &last,   CURLFORM_PTRNAME, name,   
+					 CURLFORM_PTRCONTENTS, value, CURLFORM_END);  
+    }
+/* 	curl_easy_setopt(handle, CURLOPT_HTTPPOST, post);   */
+    return AXIS2_SUCCESS;
 }



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


Mime
View raw message