-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I have added some functionality to the server side code of the axis2
http transport module. Please apply the patch and commit the code.
- - Sahan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iQEVAwUBQ8UllqnIlEsDdb85AQIHAAf7Bt59DxtnAgbvDnUnwb7X2hvdi7vjlUlF
TuJ9JLqTvN5bJ9LAasNU8x0o+FtOQIikI2RM5sP9C3aKQogtTlV0GM6HU2GX50g2
J+uQx9L+DndHTqYG3SsBOh1i51oQtQEMknk2NXcLN16P03krAxpvdK1+qnBXqoCg
ETLgipG2ig9qxfvlLvvOdMlaLvrL91QXHtrvMlm71jbbOeeYH+MHxUwP9TyD7Tp5
vP/rvxLgpLCcDYC4d+D/1AYWKg/vQesw06UpzLlFlkQg/anxe/+oPtSsWqiEXEyS
sZEfnxtO9mo03gXBLdMUvkAy7pE9LdAOgDPTICTiXsTBO5P639bgbg==
=D3Fs
-----END PGP SIGNATURE-----
Index: include/axis2_error.h
===================================================================
--- include/axis2_error.h (revision 368038)
+++ include/axis2_error.h (working copy)
@@ -380,7 +380,9 @@
/* Invalid messge addition , operation context completed */
AXIS2_ERROR_INVALID_MESSAGE_ADDITION,
- AXIS2_ERROR_INVALID_SOAP_NAMESPACE_URI
+ AXIS2_ERROR_INVALID_SOAP_NAMESPACE_URI,
+ /* Error in writing the response in response writer */
+ AXIS2_ERROR_WRITING_RESPONSE
};
/** @} */
Index: include/axis2_simple_http_svr_conn.h
===================================================================
--- include/axis2_simple_http_svr_conn.h (revision 368038)
+++ include/axis2_simple_http_svr_conn.h (working copy)
@@ -72,7 +72,7 @@
axis2_status_t (AXIS2_CALL *write_response)
(axis2_simple_http_svr_conn_t *svr_conn,
axis2_env_t **env,
- const axis2_http_simple_response_t *response);
+ axis2_http_simple_response_t *response);
int (AXIS2_CALL *get_snd_timeout)
(axis2_simple_http_svr_conn_t *svr_conn,
axis2_env_t **env);
Index: configure.ac
===================================================================
--- configure.ac (revision 368038)
+++ configure.ac (working copy)
@@ -93,6 +93,7 @@
modules/core/phaseresolver/Makefile \
modules/core/transport/Makefile \
modules/core/transport/http/Makefile \
+ modules/core/transport/http/server/Makefile \
modules/core/deployment/Makefile \
modules/core/clientapi/Makefile \
modules/core/receivers/Makefile \
Index: modules/xml/soap/Makefile.am
===================================================================
--- modules/xml/soap/Makefile.am (revision 368038)
+++ modules/xml/soap/Makefile.am (working copy)
@@ -13,7 +13,11 @@
soap_header.c \
soap_utils.c \
soap_body.c \
- soap_envelope.c
+ soap_envelope.c\
+ soap_model_builder.c\
+ soap_message.c\
+ soap11_builder_helper.c\
+ soap12_builder_helper.c
libaxis2_soap_la_LIBADD =
INCLUDES = -I$(top_builddir)/include \
Index: modules/core/transport/http/axis2_simple_http_svr_conn.c
===================================================================
--- modules/core/transport/http/axis2_simple_http_svr_conn.c (revision
368038)
+++ modules/core/transport/http/axis2_simple_http_svr_conn.c (working copy)
@@ -16,6 +16,8 @@
#include <axis2_simple_http_svr_conn.h>
#include <unistd.h>
+#include <axis2_http_transport.h>
+#include <axis2_string.h>
/**
* @brief Simple HTTP Server Connection struct impl
@@ -70,7 +72,7 @@
axis2_simple_http_svr_conn_write_response
(axis2_simple_http_svr_conn_t *svr_conn,
axis2_env_t **env,
- const axis2_http_simple_response_t *response);
+ axis2_http_simple_response_t *response);
axis2_status_t AXIS2_CALL
axis2_simple_http_svr_conn_free(axis2_simple_http_svr_conn_t *svr_conn,
@@ -96,6 +98,17 @@
svr_conn_impl->stream = NULL;
svr_conn_impl->keep_alive = AXIS2_FALSE;
+ if(-1 != svr_conn_impl->socket)
+ {
+ svr_conn_impl->stream = axis2_stream_create_socket(env,
+ svr_conn_impl->socket);
+ if(NULL == svr_conn_impl->stream)
+ {
+
axis2_simple_http_svr_conn_free((axis2_simple_http_svr_conn_t *)
+ svr_conn_impl, env);
+ return NULL;
+ }
+ }
svr_conn_impl->svr_conn.ops = AXIS2_MALLOC((*env)->allocator,
sizeof(axis2_simple_http_svr_conn_ops_t));
if(NULL == svr_conn_impl->svr_conn.ops)
@@ -238,23 +251,145 @@
axis2_simple_http_svr_conn_read_request(axis2_simple_http_svr_conn_t
*svr_conn,
axis2_env_t **env)
{
+ axis2_char_t str_line[1024];
+ axis2_char_t tmp_buf[3];
+ axis2_simple_http_svr_conn_impl_t *svr_conn_impl = NULL;
+ int read = -1;
+ axis2_bool_t end_of_line = AXIS2_FALSE;
+ axis2_bool_t end_of_headers = AXIS2_FALSE;
+ axis2_http_request_line_t *request_line = NULL;
+ axis2_http_simple_request_t *request = NULL;
+
AXIS2_FUNC_PARAM_CHECK(svr_conn, env, NULL);
- /*
- TODO stream dependant code
- */
- return NULL;
+
+ svr_conn_impl = AXIS2_INTF_TO_IMPL(svr_conn);
+ memset(str_line, 0, 1024);
+ while((read = AXIS2_STREAM_READ(svr_conn_impl->stream, env, tmp_buf,
+ 1)) > 0)
+ {
+ tmp_buf[read] = '\0';
+ strcat(str_line, tmp_buf);
+ if(0 != strstr(str_line, AXIS2_HTTP_CRLF))
+ {
+ end_of_line = AXIS2_TRUE;
+ }
+ if(AXIS2_TRUE == end_of_line)
+ {
+ break;
+ }
+ }
+ request_line = axis2_http_request_line_parse_line(env, str_line);
+ if(NULL == request_line)
+ {
+ AXIS2_ERROR_SET((*env)->error,
+
AXIS2_ERROR_INVALID_HTTP_INVALID_HEADER_START_LINE,
+ AXIS2_FAILURE);
+ return NULL;
+ }
+ request = axis2_http_simple_request_create(env, request_line, NULL , 0,
+ svr_conn_impl->stream);
+ /* now read the headers */
+ memset(str_line, 0, 1024);
+ end_of_line = AXIS2_FALSE;
+ while(AXIS2_FALSE == end_of_headers)
+ {
+ while((read = AXIS2_STREAM_READ(svr_conn_impl->stream, env,
tmp_buf,
+ 1)) > 0)
+ {
+ tmp_buf[read] = '\0';
+ strcat(str_line, tmp_buf);
+ if(0 != strstr(str_line, AXIS2_HTTP_CRLF))
+ {
+ end_of_line = AXIS2_TRUE;
+ break;
+ }
+ }
+ if(AXIS2_TRUE == end_of_line)
+ {
+ if(0 == AXIS2_STRCMP(str_line, AXIS2_HTTP_CRLF))
+ {
+ end_of_headers = AXIS2_TRUE;
+ }
+ else
+ {
+ axis2_http_header_t *tmp_header =
+
axis2_http_header_create_by_str(env, str_line);
+ memset(str_line, 0, 1024);
+ if(NULL != tmp_header)
+ {
+
AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, env,
+ tmp_header);
+ }
+ }
+ }
+ end_of_line = AXIS2_FALSE;
+ }
+ return request;
}
axis2_status_t AXIS2_CALL
axis2_simple_http_svr_conn_write_response
- (axis2_simple_http_svr_conn_t *svr_conn,
- axis2_env_t **env,
- const axis2_http_simple_response_t *response)
+ (axis2_simple_http_svr_conn_t
*svr_conn,
+ axis2_env_t **env,
+ axis2_http_simple_response_t
*response)
{
+ axis2_http_response_writer_t *response_writer = NULL;
+ axis2_simple_http_svr_conn_impl_t *svr_conn_impl = NULL;
+ axis2_array_list_t *headers = NULL;
+ axis2_stream_t *response_stream = NULL;
+ axis2_char_t *response_body = NULL;
+ int body_size = NULL;
+ int i = 0;
+
AXIS2_FUNC_PARAM_CHECK(svr_conn, env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK((*env)->error, response, AXIS2_FAILURE);
+
+ svr_conn_impl = AXIS2_INTF_TO_IMPL(svr_conn);
+ response_writer = axis2_http_response_writer_create(env,
+ svr_conn_impl->stream);
+ if(NULL == response_writer)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ AXIS2_HTTP_RESPONSE_WRITER_PRINTLN_STR(response_writer, env,
+
AXIS2_HTTP_SIMPLE_RESPONSE_GET_STAUTUS_LINE(response,
+ env));
+ headers = AXIS2_HTTP_SIMPLE_RESPONSE_GET_HEADERS(response, env);
+
+
+
+ for(i = 0; i < AXIS2_ARRAY_LIST_SIZE(headers, env); i++)
+ {
+ axis2_http_header_t *header = NULL;
+ header = (axis2_http_header_t *)AXIS2_ARRAY_LIST_GET(headers,
env, i);
+ if(NULL != header)
+ {
+ AXIS2_HTTP_RESPONSE_WRITER_PRINTLN_STR(response_writer,
env,
+
AXIS2_HTTP_HEADER_TO_EXTERNAL_FORM(
+ (axis2_http_header_t*)header,
env));
+ }
+ }
+ AXIS2_HTTP_RESPONSE_WRITER_PRINTLN(response_writer, env);
+
+ response_stream = AXIS2_HTTP_SIMPLE_RESPONSE_GET_BODY(response, env);
+ body_size = AXIS2_HTTP_SIMPLE_RESPONSE_GET_BODY_BYTES(response, env,
+ &response_body);
+ if(body_size > 0)
+ {
+ int write_size = 0;
+ write_size = AXIS2_STREAM_WRITE(response_stream, env,
response_body,
+ body_size);
+ if(write_size < 0)
+ {
+ AXIS2_ERROR_SET((*env)->error,
AXIS2_ERROR_WRITING_RESPONSE,
+ AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+ }
/*
- TODO stream dependant code
+ TODO chunking
*/
return AXIS2_SUCCESS;
}
Index: modules/core/transport/http/axis2_http_client.c
===================================================================
--- modules/core/transport/http/axis2_http_client.c (revision 368038)
+++ modules/core/transport/http/axis2_http_client.c (working copy)
@@ -284,9 +284,6 @@
if(0 != strstr(str_status_line, AXIS2_HTTP_CRLF))
{
end_of_line = AXIS2_TRUE;
- }
- if(AXIS2_TRUE == end_of_line)
- {
break;
}
}
@@ -319,9 +316,6 @@
if(0 != strstr(str_header, AXIS2_HTTP_CRLF))
{
end_of_line = AXIS2_TRUE;
- }
- if(AXIS2_TRUE == end_of_line)
- {
break;
}
}