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/25 11:34:54 UTC
svn commit: r409345 - in /webservices/axis2/trunk/c:
axiom/include/axis2_mime_const.h axiom/include/axis2_mime_parser.h
axiom/src/attachments/mime_output.c axiom/src/attachments/mime_parser.c
modules/core/transport/http/http_transport_utils.c
Author: samisa
Date: Thu May 25 02:34:53 2006
New Revision: 409345
URL: http://svn.apache.org/viewvc?rev=409345&view=rev
Log:
Moving mime parsing logic from transport util to a seperate mime parser
Added:
webservices/axis2/trunk/c/axiom/include/axis2_mime_const.h
Modified:
webservices/axis2/trunk/c/axiom/include/axis2_mime_parser.h
webservices/axis2/trunk/c/axiom/src/attachments/mime_output.c
webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c
webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
Added: webservices/axis2/trunk/c/axiom/include/axis2_mime_const.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/include/axis2_mime_const.h?rev=409345&view=auto
==============================================================================
--- webservices/axis2/trunk/c/axiom/include/axis2_mime_const.h (added)
+++ webservices/axis2/trunk/c/axiom/include/axis2_mime_const.h Thu May 25 02:34:53 2006
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AXIS2_MIME_CONST_H
+#define AXIS2_MIME_CONST_H
+
+/**
+* @file axis2_om.h
+* @brief includes all headers in MIME_CONST
+*/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define AXIS2_MIME_BOUNDARY_BYTE 45
+#define AXIS2_MIME_CRLF_BYTE 13
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AXIS2_MIME_CONST_H */
Modified: webservices/axis2/trunk/c/axiom/include/axis2_mime_parser.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/include/axis2_mime_parser.h?rev=409345&r1=409344&r2=409345&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/include/axis2_mime_parser.h (original)
+++ webservices/axis2/trunk/c/axiom/include/axis2_mime_parser.h Thu May 25 02:34:53 2006
@@ -29,7 +29,7 @@
#include <axis2_allocator.h>
#include <axis2_string.h>
#include <axis2_hash.h>
-
+#include <axis2_mime_const.h>
#ifdef __cplusplus
extern "C"
@@ -55,7 +55,9 @@
parse)(
axis2_mime_parser_t *mime_parser,
axis2_env_t **env,
- AXIS2_READ_INPUT_CALLBACK);
+ AXIS2_READ_INPUT_CALLBACK,
+ void *callback_ctx,
+ axis2_char_t *mime_boundary);
axis2_hash_t* (AXIS2_CALL *
get_mime_parts_map)(
@@ -69,6 +71,11 @@
free)(
axis2_mime_parser_t *mime_parser,
axis2_env_t **env);
+
+ int (AXIS2_CALL *
+ get_soap_body_len)(
+ axis2_mime_parser_t *mime_parser,
+ axis2_env_t **env);
};
/**
@@ -93,10 +100,13 @@
((mime_parser)->ops->free (mime_parser, env))
#define AXIS2_MIME_PARSER_PARSE(mime_parser, env, callback) \
-((mime_parser)->ops->parse(mime_parser, env, callback))
+((mime_parser)->ops->parse(mime_parser, env, callback, callback_ctx, mime_boundary))
#define AXIS2_MIME_PARSER_GET_MIME_PARTS_MAP(mime_parser, env) \
((mime_parser)->ops->get_mime_parts_map(mime_parser, env))
+
+#define AXIS2_MIME_PARSER_GET_SOAP_BODY_LENGTH(mime_parser, env) \
+((mime_parser)->ops->get_soap_body_len(mime_parser, env))
/*************************** End of function macros ***************************/
Modified: webservices/axis2/trunk/c/axiom/src/attachments/mime_output.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/attachments/mime_output.c?rev=409345&r1=409344&r2=409345&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/attachments/mime_output.c (original)
+++ webservices/axis2/trunk/c/axiom/src/attachments/mime_output.c Thu May 25 02:34:53 2006
@@ -19,6 +19,7 @@
#include "axis2_mime_body_part.h"
#include <axis2_string.h>
#include <axis2_om_text.h>
+#include <axis2_mime_const.h>
axis2_char_t AXIS2_CRLF[] = { 13, 10 };
@@ -28,13 +29,11 @@
} axis2_mime_output_impl_t;
#define AXIS2_INTF_TO_IMPL(mime_output) ((axis2_mime_output_impl_t *)(mime_output))
-#define AXIS2_MIME_BOUNDARY_BYTE 45
-#define AXIS2_MIME_CRLF_BYTE 13
axis2_status_t axis2_char_2_byte(axis2_env_t **env, axis2_char_t *char_buffer, axis2_byte_t **byte_buffer, int *byte_buffer_size);
-axis2_status_t
+axis2_status_t
axis2_char_2_byte(axis2_env_t **env, axis2_char_t *char_buffer, axis2_byte_t **byte_buffer, int *byte_buffer_size)
{
int length;
Modified: webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c?rev=409345&r1=409344&r2=409345&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c (original)
+++ webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c Thu May 25 02:34:53 2006
@@ -16,15 +16,19 @@
#include <axis2_mime_parser.h>
#include <axis2_string.h>
+#include <axis2_data_handler.h>
typedef struct axis2_mime_parser_impl
{
axis2_mime_parser_t mime_parser;
axis2_hash_t *mime_parts_map;
+ int soap_body_len;
} axis2_mime_parser_impl_t;
#define AXIS2_INTF_TO_IMPL(mime_parser) ((axis2_mime_parser_impl_t *)(mime_parser))
+#define AXIS2_MIME_PARSER_BUFFER_SIZE (1024 * 1024)
+
/***************************** Function headers *******************************/
axis2_status_t AXIS2_CALL
@@ -33,12 +37,18 @@
axis2_hash_t* AXIS2_CALL
axis2_mime_parser_parse(axis2_mime_parser_t *mime_parser,
axis2_env_t **env,
- AXIS2_READ_INPUT_CALLBACK);
+ AXIS2_READ_INPUT_CALLBACK,
+ void *callback_ctx,
+ axis2_char_t *mime_boundary);
axis2_hash_t* AXIS2_CALL
axis2_mime_parser_get_mime_parts_map(axis2_mime_parser_t *mime_parser,
axis2_env_t **env);
+int AXIS2_CALL
+axis2_mime_parser_get_soap_body_len(axis2_mime_parser_t *mime_parser,
+ axis2_env_t **env);
+
/************************** End of Function headers ************************/
AXIS2_DECLARE(axis2_mime_parser_t *)
@@ -58,6 +68,7 @@
mime_parser_impl->mime_parser.ops = NULL;
mime_parser_impl->mime_parts_map = NULL;
+ mime_parser_impl->soap_body_len = 0;
mime_parser_impl->mime_parts_map = axis2_hash_make(env);
if (!(mime_parser_impl->mime_parts_map))
@@ -118,12 +129,287 @@
axis2_hash_t* AXIS2_CALL
axis2_mime_parser_parse(axis2_mime_parser_t *mime_parser,
axis2_env_t **env,
- AXIS2_READ_INPUT_CALLBACK callback)
+ AXIS2_READ_INPUT_CALLBACK callback,
+ void *callback_ctx,
+ axis2_char_t *mime_boundary)
{
axis2_mime_parser_impl_t *mime_parser_impl = NULL;
+ axis2_char_t *buffer = NULL;
+ int size = AXIS2_MIME_PARSER_BUFFER_SIZE;
+ int len = 0;
+ axis2_char_t *root_mime = NULL;
+ int root_mime_len = 0;
+ axis2_char_t *soap_body_str = NULL;
+ int soap_body_len = 0;
+ axis2_char_t *body_mime = NULL;
+ int body_mime_len = 0;
+ axis2_char_t *mime_binary = NULL;
+ int mime_binary_len = 0;
+ axis2_char_t *pos = NULL;
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
mime_parser_impl = AXIS2_INTF_TO_IMPL(mime_parser);
+
+ buffer = AXIS2_MALLOC((*env)->allocator, sizeof(axis2_char_t) * (size + 1));
+
+ do
+ {
+ len = callback(buffer, size, (void*)callback_ctx);
+ if (len > 0)
+ {
+ axis2_char_t *temp_root_mime = root_mime;
+ root_mime = AXIS2_MALLOC((*env)->allocator,
+ sizeof(char) * (root_mime_len + len + 1));
+ if (root_mime)
+ {
+ if (temp_root_mime)
+ {
+ memcpy(root_mime, temp_root_mime, root_mime_len);
+ AXIS2_FREE((*env)->allocator, temp_root_mime);
+ temp_root_mime = NULL;
+ }
+
+ memcpy(root_mime + root_mime_len, buffer, len);
+ root_mime_len += len;
+ root_mime[root_mime_len] = '\0';
+
+ pos = AXIS2_STRSTR(root_mime, "\r\n\r\n");
+ if (pos)
+ {
+ if (root_mime_len > (pos - root_mime + 4))
+ {
+ soap_body_len = root_mime_len - (pos - root_mime + 4);
+ soap_body_str = AXIS2_MALLOC((*env)->allocator,
+ sizeof(char) * (soap_body_len + 1));
+ memcpy(soap_body_str, pos + 4, soap_body_len);
+ soap_body_str[soap_body_len] = '\0';
+ *pos = '\0';
+ }
+ }
+ }
+ }
+
+ } while(!pos && len > 0);
+
+ pos = NULL;
+ len = 0;
+
+ do
+ {
+ if (soap_body_str)
+ {
+ pos = AXIS2_STRSTR(soap_body_str, mime_boundary);
+ }
+
+ if (pos)
+ {
+ pos -= 2;
+ body_mime_len = soap_body_len - (pos - soap_body_str);
+ body_mime = AXIS2_MALLOC((*env)->allocator,
+ sizeof(char) * (body_mime_len + 1));
+ memcpy(body_mime, pos, body_mime_len);
+ body_mime[body_mime_len] = '\0';
+
+ *(pos) = '\0';
+ soap_body_len = (pos - soap_body_str);
+ }
+ else
+ {
+ len = callback(buffer, size, (void*)callback_ctx);
+ if (len > 0)
+ {
+ axis2_char_t *temp_soap_body = soap_body_str;
+ soap_body_str = AXIS2_MALLOC((*env)->allocator,
+ sizeof(char) * (soap_body_len + len + 1));
+ if (soap_body_str)
+ {
+ if (temp_soap_body)
+ {
+ memcpy(soap_body_str, temp_soap_body, soap_body_len);
+ AXIS2_FREE((*env)->allocator, temp_soap_body);
+ temp_soap_body = NULL;
+ }
+
+ memcpy(soap_body_str + soap_body_len, buffer, len);
+ soap_body_len += len;
+ soap_body_str[soap_body_len] = '\0';
+ }
+ }
+ }
+ } while(!pos && len > 0);
+
+ pos = NULL;
+ len = 0;
+
+ do
+ {
+ if (body_mime)
+ {
+ pos = AXIS2_STRSTR(body_mime, "\r\n\r\n");
+ }
+
+ if (pos)
+ {
+ if (body_mime_len > (pos - body_mime + 4))
+ {
+ mime_binary_len = body_mime_len - (pos - body_mime + 4);
+ mime_binary = AXIS2_MALLOC((*env)->allocator,
+ sizeof(char) * (mime_binary_len + 1));
+ memcpy(mime_binary, pos + 4, mime_binary_len);
+ mime_binary[mime_binary_len] = '\0';
+ *pos = '\0';
+ }
+ }
+ else
+ {
+ len = callback(buffer, size, (void*)callback_ctx);
+ if (len > 0)
+ {
+ axis2_char_t *temp_body_mime = body_mime;
+ body_mime = AXIS2_MALLOC((*env)->allocator,
+ sizeof(char) * (body_mime_len + len + 1));
+ if (body_mime)
+ {
+ if (temp_body_mime)
+ {
+ memcpy(body_mime, temp_body_mime, body_mime_len);
+ AXIS2_FREE((*env)->allocator, temp_body_mime);
+ temp_body_mime = NULL;
+ }
+
+ memcpy(body_mime + body_mime_len, buffer, len);
+ body_mime_len += len;
+ body_mime[body_mime_len] = '\0';
+ }
+ }
+ }
+ } while(!pos && len > 0);
+
+
+ /* TODO: need to address the ultiple attachment case */
+ pos = NULL;
+ len = 0;
+ do
+ {
+ axis2_char_t *old_pos = NULL;
+ if (mime_binary)
+ {
+ axis2_char_t *temp_pos = NULL;
+ old_pos = mime_binary;
+
+ do
+ {
+
+ pos = memchr(old_pos, AXIS2_MIME_BOUNDARY_BYTE,
+ (mime_binary_len - (old_pos - mime_binary)));
+ if (!pos)
+ break;
+ else
+ {
+ old_pos = pos + 1;
+ if (old_pos - mime_binary > mime_binary_len)
+ {
+ pos = NULL;
+ break;
+ }
+ temp_pos = AXIS2_STRSTR(pos + 1, mime_boundary);
+ }
+ } while ( *(pos + 1) != AXIS2_MIME_BOUNDARY_BYTE || temp_pos != pos + 2);
+
+ if ( pos && *(pos + 1) == AXIS2_MIME_BOUNDARY_BYTE && temp_pos == pos + 2)
+ {
+ mime_binary_len = pos - mime_binary;
+ }
+ else
+ pos = NULL;
+ }
+
+ if (!pos)
+ {
+ len = callback(buffer, size, (void*)callback_ctx);
+ if (len > 0)
+ {
+ axis2_char_t *temp_mime_binary = mime_binary;
+ mime_binary = AXIS2_MALLOC((*env)->allocator,
+ sizeof(char) * (mime_binary_len + len + 1));
+ if (mime_binary)
+ {
+ if (temp_mime_binary)
+ {
+ memcpy(mime_binary, temp_mime_binary, mime_binary_len);
+ AXIS2_FREE((*env)->allocator, temp_mime_binary);
+ temp_mime_binary = NULL;
+ }
+
+ memcpy(mime_binary + mime_binary_len, buffer, len);
+ mime_binary_len += len;
+ mime_binary[mime_binary_len] = '\0';
+ }
+ }
+ }
+
+ } while(!pos && len > 0);
+
+ if (soap_body_str)
+ {
+ mime_parser_impl->soap_body_len = soap_body_len;
+ /* create a basic stream with soap string to pull SOAP */
+ /*axis2_stream_t *stream = axis2_stream_create_basic(env);
+ if (stream)
+ {
+ AXIS2_STREAM_WRITE(stream, env, soap_body_str, soap_body_len);
+ callback_ctx.in_stream = stream;
+ callback_ctx.chunked_stream = NULL;
+ callback_ctx.content_length = soap_body_len;
+ callback_ctx.unread_len = soap_body_len;
+ }*/
+
+ /* data handler hash map */
+ /*binary_data_map = axis2_hash_make(env);*/
+ if (mime_parser_impl->mime_parts_map)
+ {
+ /* get MIME ID */
+ axis2_char_t *id = NULL;
+ id = AXIS2_STRSTR(body_mime, "content-id");
+ if (id)
+ {
+ id += AXIS2_STRLEN("content-id");
+ while (id && *id && *id != ':')
+ id++;
+ if (id)
+ {
+ while (id && *id && *id != '<')
+ id++;
+ id++;
+ if (id)
+ {
+ axis2_char_t *pos = NULL;
+ pos = AXIS2_STRSTR(id, ">");
+ if (pos)
+ {
+ axis2_char_t *mime_id = NULL;
+ int mime_id_len = 0;
+ mime_id_len = pos - id;
+ mime_id = AXIS2_MALLOC((*env)->allocator,
+ sizeof(axis2_char_t) * mime_id_len + 1);
+ if (mime_id)
+ {
+ axis2_data_handler_t *data_handler = NULL;
+ memcpy(mime_id, id, mime_id_len);
+ mime_id[mime_id_len] = '\0';
+ data_handler = axis2_data_handler_create(env, NULL, NULL);
+ AXIS2_DATA_HANDLER_SET_BINARY_DATA(data_handler, env,
+ mime_binary, mime_binary_len);
+ axis2_hash_set(mime_parser_impl->mime_parts_map, mime_id,
+ AXIS2_HASH_KEY_STRING, data_handler);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
return mime_parser_impl->mime_parts_map;
}
@@ -133,4 +419,12 @@
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
return AXIS2_INTF_TO_IMPL(mime_parser)->mime_parts_map;
+}
+
+int AXIS2_CALL
+axis2_mime_parser_get_soap_body_len(axis2_mime_parser_t *mime_parser,
+ axis2_env_t **env)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ return AXIS2_INTF_TO_IMPL(mime_parser)->soap_body_len;
}
Modified: webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c?rev=409345&r1=409344&r2=409345&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c Thu May 25 02:34:53 2006
@@ -32,6 +32,7 @@
#include <axis2_http_header.h>
#include <axis2_property.h>
#include <axis2_utils.h>
+#include <axis2_mime_parser.h>
#define AXIS2_MIME_BOUNDARY_BYTE 45
@@ -199,278 +200,29 @@
if (mime_boundary)
{
- axis2_char_t *buffer = NULL;
- int size = 1024 * 1024;
- int len = 0;
- axis2_char_t *root_mime = NULL;
- int root_mime_len = 0;
- axis2_char_t *soap_body_str = NULL;
+ axis2_mime_parser_t *mime_parser = NULL;
+ axis2_stream_t *stream = NULL;
int soap_body_len = 0;
- axis2_char_t *body_mime = NULL;
- int body_mime_len = 0;
- axis2_char_t *mime_binary = NULL;
- int mime_binary_len = 0;
- axis2_char_t *pos = NULL;
- buffer = AXIS2_MALLOC((*env)->allocator, sizeof(axis2_char_t) * (size + 1));
-
- do
- {
- len = axis2_http_transport_utils_on_data_request(buffer, size, (void*)&callback_ctx);
- if (len > 0)
- {
- axis2_char_t *temp_root_mime = root_mime;
- root_mime = AXIS2_MALLOC((*env)->allocator,
- sizeof(char) * (root_mime_len + len + 1));
- if (root_mime)
- {
- if (temp_root_mime)
- {
- memcpy(root_mime, temp_root_mime, root_mime_len);
- AXIS2_FREE((*env)->allocator, temp_root_mime);
- temp_root_mime = NULL;
- }
-
- memcpy(root_mime + root_mime_len, buffer, len);
- root_mime_len += len;
- root_mime[root_mime_len] = '\0';
-
- pos = AXIS2_STRSTR(root_mime, "\r\n\r\n");
- if (pos)
- {
- if (root_mime_len > (pos - root_mime + 4))
- {
- soap_body_len = root_mime_len - (pos - root_mime + 4);
- soap_body_str = AXIS2_MALLOC((*env)->allocator,
- sizeof(char) * (soap_body_len + 1));
- memcpy(soap_body_str, pos + 4, soap_body_len);
- soap_body_str[soap_body_len] = '\0';
- *pos = '\0';
- }
- }
- }
- }
-
- } while(!pos && len > 0);
-
- pos = NULL;
- len = 0;
-
- do
- {
- if (soap_body_str)
- {
- pos = AXIS2_STRSTR(soap_body_str, mime_boundary);
- }
-
- if (pos)
- {
- pos -= 2;
- body_mime_len = soap_body_len - (pos - soap_body_str);
- body_mime = AXIS2_MALLOC((*env)->allocator,
- sizeof(char) * (body_mime_len + 1));
- memcpy(body_mime, pos, body_mime_len);
- body_mime[body_mime_len] = '\0';
-
- *(pos) = '\0';
- soap_body_len = (pos - soap_body_str);
- }
- else
- {
- len = axis2_http_transport_utils_on_data_request(buffer, size, (void*)&callback_ctx);
- if (len > 0)
- {
- axis2_char_t *temp_soap_body = soap_body_str;
- soap_body_str = AXIS2_MALLOC((*env)->allocator,
- sizeof(char) * (soap_body_len + len + 1));
- if (soap_body_str)
- {
- if (temp_soap_body)
- {
- memcpy(soap_body_str, temp_soap_body, soap_body_len);
- AXIS2_FREE((*env)->allocator, temp_soap_body);
- temp_soap_body = NULL;
- }
-
- memcpy(soap_body_str + soap_body_len, buffer, len);
- soap_body_len += len;
- soap_body_str[soap_body_len] = '\0';
- }
- }
- }
- } while(!pos && len > 0);
-
- pos = NULL;
- len = 0;
-
- do
- {
- if (body_mime)
- {
- pos = AXIS2_STRSTR(body_mime, "\r\n\r\n");
- }
-
- if (pos)
- {
- if (body_mime_len > (pos - body_mime + 4))
- {
- mime_binary_len = body_mime_len - (pos - body_mime + 4);
- mime_binary = AXIS2_MALLOC((*env)->allocator,
- sizeof(char) * (mime_binary_len + 1));
- memcpy(mime_binary, pos + 4, mime_binary_len);
- mime_binary[mime_binary_len] = '\0';
- *pos = '\0';
- }
- }
- else
- {
- len = axis2_http_transport_utils_on_data_request(buffer, size, (void*)&callback_ctx);
- if (len > 0)
- {
- axis2_char_t *temp_body_mime = body_mime;
- body_mime = AXIS2_MALLOC((*env)->allocator,
- sizeof(char) * (body_mime_len + len + 1));
- if (body_mime)
- {
- if (temp_body_mime)
- {
- memcpy(body_mime, temp_body_mime, body_mime_len);
- AXIS2_FREE((*env)->allocator, temp_body_mime);
- temp_body_mime = NULL;
- }
-
- memcpy(body_mime + body_mime_len, buffer, len);
- body_mime_len += len;
- body_mime[body_mime_len] = '\0';
- }
- }
- }
- } while(!pos && len > 0);
-
-
- /* TODO: need to address the ultiple attachment case */
- pos = NULL;
- len = 0;
- do
+ mime_parser = axis2_mime_parser_create(env);
+ if (mime_parser)
{
- axis2_char_t *old_pos = NULL;
- if (mime_binary)
- {
- axis2_char_t *temp_pos = NULL;
- old_pos = mime_binary;
-
- do
- {
-
- pos = memchr(old_pos, AXIS2_MIME_BOUNDARY_BYTE,
- (mime_binary_len - (old_pos - mime_binary)));
- if (!pos)
- break;
- else
- {
- old_pos = pos + 1;
- if (old_pos - mime_binary > mime_binary_len)
- {
- pos = NULL;
- break;
- }
- temp_pos = AXIS2_STRSTR(pos + 1, mime_boundary);
- }
- } while ( *(pos + 1) != AXIS2_MIME_BOUNDARY_BYTE || temp_pos != pos + 2);
-
- if ( pos && *(pos + 1) == AXIS2_MIME_BOUNDARY_BYTE && temp_pos == pos + 2)
- {
- mime_binary_len = pos - mime_binary;
- }
- else
- pos = NULL;
- }
-
- if (!pos)
- {
- len = axis2_http_transport_utils_on_data_request(buffer, size, (void*)&callback_ctx);
- if (len > 0)
- {
- axis2_char_t *temp_mime_binary = mime_binary;
- mime_binary = AXIS2_MALLOC((*env)->allocator,
- sizeof(char) * (mime_binary_len + len + 1));
- if (mime_binary)
- {
- if (temp_mime_binary)
- {
- memcpy(mime_binary, temp_mime_binary, mime_binary_len);
- AXIS2_FREE((*env)->allocator, temp_mime_binary);
- temp_mime_binary = NULL;
- }
-
- memcpy(mime_binary + mime_binary_len, buffer, len);
- mime_binary_len += len;
- mime_binary[mime_binary_len] = '\0';
- }
- }
- }
+ binary_data_map = AXIS2_MIME_PARSER_PARSE(mime_parser, env,
+ axis2_http_transport_utils_on_data_request,
+ callback_ctx, mime_boundary);
+
+ soap_body_len = AXIS2_MIME_PARSER_GET_SOAP_BODY_LENGTH(
+ mime_parser, env);
+ }
- } while(!pos && len > 0);
-
- if (soap_body_str)
+ stream = axis2_stream_create_basic(env);
+ if (stream)
{
- /* create a basic stream with soap string to pull SOAP */
- axis2_stream_t *stream = axis2_stream_create_basic(env);
- if (stream)
- {
- AXIS2_STREAM_WRITE(stream, env, soap_body_str, soap_body_len);
- callback_ctx.in_stream = stream;
- callback_ctx.chunked_stream = NULL;
- callback_ctx.content_length = soap_body_len;
- callback_ctx.unread_len = soap_body_len;
- }
-
- /* data handler hash map */
- binary_data_map = axis2_hash_make(env);
- if (binary_data_map)
- {
- /* get MIME ID */
- axis2_char_t *id = NULL;
- id = AXIS2_STRSTR(body_mime, "content-id");
- if (id)
- {
- id += AXIS2_STRLEN("content-id");
- while (id && *id && *id != ':')
- id++;
- if (id)
- {
- while (id && *id && *id != '<')
- id++;
- id++;
- if (id)
- {
- axis2_char_t *pos = NULL;
- pos = AXIS2_STRSTR(id, ">");
- if (pos)
- {
- axis2_char_t *mime_id = NULL;
- int mime_id_len = 0;
- mime_id_len = pos - id;
- mime_id = AXIS2_MALLOC((*env)->allocator,
- sizeof(axis2_char_t) * mime_id_len + 1);
- if (mime_id)
- {
- axis2_data_handler_t *data_handler = NULL;
- memcpy(mime_id, id, mime_id_len);
- mime_id[mime_id_len] = '\0';
- data_handler = axis2_data_handler_create(env, NULL, NULL);
- AXIS2_DATA_HANDLER_SET_BINARY_DATA(data_handler, env,
- mime_binary, mime_binary_len);
- axis2_hash_set(binary_data_map, mime_id,
- AXIS2_HASH_KEY_STRING, data_handler);
- }
- }
- }
- }
- }
- }
-
-
+ AXIS2_STREAM_WRITE(stream, env, soap_body_str, soap_body_len);
+ callback_ctx.in_stream = stream;
+ callback_ctx.chunked_stream = NULL;
+ callback_ctx.content_length = soap_body_len;
+ callback_ctx.unread_len = soap_body_len;
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org