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 sa...@apache.org on 2007/09/28 11:53:04 UTC
svn commit: r580276 [17/26] - in /webservices/axis2/trunk/c/src: core/addr/
core/clientapi/ core/context/ core/deployment/ core/description/
core/engine/ core/phaseresolver/ core/receivers/ core/transport/
core/transport/http/common/ core/transport/htt...
Modified: webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c?rev=580276&r1=580275&r2=580276&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c Fri Sep 28 02:52:58 2007
@@ -1,3 +1,4 @@
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +16,6 @@
* limitations under the License.
*/
-
#include <axis2_http_worker.h>
#include <axutil_string.h>
#include <axis2_http_transport.h>
@@ -39,53 +39,50 @@
int svr_port;
};
-static axis2_status_t
-axis2_http_worker_set_response_headers(
- axis2_http_worker_t *http_worker,
- const axutil_env_t *env,
- axis2_simple_http_svr_conn_t *svr_conn,
- axis2_http_simple_request_t *simple_request,
- axis2_http_simple_response_t *simple_response,
+static axis2_status_t axis2_http_worker_set_response_headers(
+ axis2_http_worker_t * http_worker,
+ const axutil_env_t * env,
+ axis2_simple_http_svr_conn_t * svr_conn,
+ axis2_http_simple_request_t * simple_request,
+ axis2_http_simple_response_t * simple_response,
axis2_ssize_t content_length);
-static axis2_status_t
-axis2_http_worker_set_transport_out_config(
- axis2_http_worker_t *http_worker,
- const axutil_env_t *env,
- axis2_conf_ctx_t *conf_ctx,
- axis2_http_simple_response_t *simple_response);
-
-static axutil_hash_t *
-axis2_http_worker_get_headers(
- axis2_http_worker_t *http_worker,
- const axutil_env_t *env,
- axis2_http_simple_request_t *request);
+static axis2_status_t axis2_http_worker_set_transport_out_config(
+ axis2_http_worker_t * http_worker,
+ const axutil_env_t * env,
+ axis2_conf_ctx_t * conf_ctx,
+ axis2_http_simple_response_t * simple_response);
+
+static axutil_hash_t *axis2_http_worker_get_headers(
+ axis2_http_worker_t * http_worker,
+ const axutil_env_t * env,
+ axis2_http_simple_request_t * request);
AXIS2_EXTERN axis2_http_worker_t *AXIS2_CALL
axis2_http_worker_create(
- const axutil_env_t *env,
- axis2_conf_ctx_t *conf_ctx)
+ const axutil_env_t * env,
+ axis2_conf_ctx_t * conf_ctx)
{
axis2_http_worker_t *http_worker = NULL;
AXIS2_ENV_CHECK(env, NULL);
http_worker = (axis2_http_worker_t *)
- AXIS2_MALLOC(env->allocator, sizeof(axis2_http_worker_t));
+ AXIS2_MALLOC(env->allocator, sizeof(axis2_http_worker_t));
- if (! http_worker)
+ if (!http_worker)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return NULL;
}
http_worker->conf_ctx = conf_ctx;
- http_worker->svr_port = 9090; /* default - must set later*/
+ http_worker->svr_port = 9090; /* default - must set later */
return http_worker;
}
AXIS2_EXTERN void AXIS2_CALL
axis2_http_worker_free(
- axis2_http_worker_t *http_worker,
- const axutil_env_t *env)
+ axis2_http_worker_t * http_worker,
+ const axutil_env_t * env)
{
AXIS2_ENV_CHECK(env, void);
@@ -98,10 +95,10 @@
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_http_worker_process_request(
- axis2_http_worker_t *http_worker,
- const axutil_env_t *env,
- axis2_simple_http_svr_conn_t *svr_conn,
- axis2_http_simple_request_t *simple_request)
+ axis2_http_worker_t * http_worker,
+ const axutil_env_t * env,
+ axis2_simple_http_svr_conn_t * svr_conn,
+ axis2_http_simple_request_t * simple_request)
{
axis2_conf_ctx_t *conf_ctx = NULL;
axis2_msg_ctx_t *msg_ctx = NULL;
@@ -135,47 +132,51 @@
conf_ctx = http_worker->conf_ctx;
- if (! conf_ctx)
+ if (!conf_ctx)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NULL_CONFIGURATION_CONTEXT,
- AXIS2_FAILURE);
+ AXIS2_FAILURE);
return AXIS2_FALSE;
}
- content_length = axis2_http_simple_request_get_content_length(simple_request
- , env);
- http_version = axis2_http_request_line_get_http_version
- (axis2_http_simple_request_get_request_line
- (simple_request, env), env);
- if (! http_version)
+ content_length =
+ axis2_http_simple_request_get_content_length(simple_request, env);
+ http_version =
+ axis2_http_request_line_get_http_version
+ (axis2_http_simple_request_get_request_line(simple_request, env), env);
+ if (!http_version)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NULL_HTTP_VERSION,
- AXIS2_FAILURE);
+ AXIS2_FAILURE);
return AXIS2_FAILURE;
}
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Client HTTP version %s",
- http_version);
+ http_version);
response = axis2_http_simple_response_create_default(env);
encoding_header = axis2_http_simple_request_get_first_header(simple_request,
- env, AXIS2_HTTP_HEADER_TRANSFER_ENCODING);
+ env,
+ AXIS2_HTTP_HEADER_TRANSFER_ENCODING);
if (encoding_header)
{
encoding_header_value = axis2_http_header_get_value(encoding_header,
- env);
+ env);
}
if (content_length < 0 && (encoding_header_value && 0 != axutil_strcmp
- (encoding_header_value,
- AXIS2_HTTP_HEADER_TRANSFER_ENCODING_CHUNKED)))
+ (encoding_header_value,
+ AXIS2_HTTP_HEADER_TRANSFER_ENCODING_CHUNKED)))
{
- if (0 == axutil_strcasecmp(axis2_http_request_line_get_method(
- axis2_http_simple_request_get_request_line(
- simple_request, env), env), AXIS2_HTTP_POST))
+ if (0 ==
+ axutil_strcasecmp(axis2_http_request_line_get_method
+ (axis2_http_simple_request_get_request_line
+ (simple_request, env), env), AXIS2_HTTP_POST))
{
axis2_http_simple_response_set_status_line(response, env,
- http_version, 411, "Length Required");
- status = axis2_simple_http_svr_conn_write_response(svr_conn, env,
- response);
+ http_version, 411,
+ "Length Required");
+ status =
+ axis2_simple_http_svr_conn_write_response(svr_conn, env,
+ response);
axis2_http_simple_response_free(response, env);
response = NULL;
return status;
@@ -184,20 +185,19 @@
}
request_body = axis2_http_simple_request_get_body(simple_request, env);
- out_desc = axis2_conf_get_transport_out( axis2_conf_ctx_get_conf
- (http_worker->conf_ctx, env), env,
- AXIS2_TRANSPORT_ENUM_HTTP);
- in_desc = axis2_conf_get_transport_in( axis2_conf_ctx_get_conf
- (http_worker->conf_ctx, env), env,
- AXIS2_TRANSPORT_ENUM_HTTP);
+ out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf
+ (http_worker->conf_ctx, env), env,
+ AXIS2_TRANSPORT_ENUM_HTTP);
+ in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf
+ (http_worker->conf_ctx, env), env,
+ AXIS2_TRANSPORT_ENUM_HTTP);
msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc);
axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);
-
if (0 == axutil_strcasecmp(http_version, AXIS2_HTTP_HEADER_PROTOCOL_11))
{
axis2_http_worker_set_transport_out_config(http_worker, env, conf_ctx,
- response);
+ response);
}
svr_ip = axis2_simple_http_svr_conn_get_svr_ip(svr_conn, env);
@@ -205,21 +205,22 @@
if (peer_ip)
{
- peer_property = axutil_property_create (env);
- axutil_property_set_value (peer_property, env, axutil_strdup (env, peer_ip));
- axis2_msg_ctx_set_property (msg_ctx, env, AXIS2_SVR_PEER_IP_ADDR, peer_property);
+ peer_property = axutil_property_create(env);
+ axutil_property_set_value(peer_property, env,
+ axutil_strdup(env, peer_ip));
+ axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_SVR_PEER_IP_ADDR,
+ peer_property);
}
- path = axis2_http_request_line_get_uri(
- axis2_http_simple_request_get_request_line(
- simple_request, env), env);
+ path =
+ axis2_http_request_line_get_uri
+ (axis2_http_simple_request_get_request_line(simple_request, env), env);
request_url = axutil_url_create(env, "http", svr_ip,
- http_worker->svr_port,
- path);
+ http_worker->svr_port, path);
+
+ url_external_form = axutil_url_to_external_form(request_url, env);
- url_external_form = axutil_url_to_external_form(request_url, env);
-
axis2_msg_ctx_set_transport_out_stream(msg_ctx, env, out_stream);
headers = axis2_http_worker_get_headers(http_worker, env, simple_request);
@@ -228,37 +229,41 @@
svc_grp_uuid = axutil_uuid_gen(env);
if (svc_grp_uuid)
{
- axutil_string_t *svc_grp_uuid_str = axutil_string_create_assume_ownership(env, &svc_grp_uuid);
- axis2_msg_ctx_set_svc_grp_ctx_id(msg_ctx, env, svc_grp_uuid_str);
+ axutil_string_t *svc_grp_uuid_str =
+ axutil_string_create_assume_ownership(env, &svc_grp_uuid);
+ axis2_msg_ctx_set_svc_grp_ctx_id(msg_ctx, env, svc_grp_uuid_str);
axutil_string_free(svc_grp_uuid_str, env);
}
- http_out_transport_info = axis2_http_out_transport_info_create(env, response);
- axis2_msg_ctx_set_http_out_transport_info(msg_ctx, env, http_out_transport_info);
+ http_out_transport_info =
+ axis2_http_out_transport_info_create(env, response);
+ axis2_msg_ctx_set_http_out_transport_info(msg_ctx, env,
+ http_out_transport_info);
if (axis2_http_simple_request_get_first_header(simple_request, env,
- AXIS2_HTTP_HEADER_SOAP_ACTION))
+ AXIS2_HTTP_HEADER_SOAP_ACTION))
{
- soap_action = axis2_http_header_get_value(
- axis2_http_simple_request_get_first_header(
- simple_request, env, AXIS2_HTTP_HEADER_SOAP_ACTION),
- env);
+ soap_action =
+ axis2_http_header_get_value
+ (axis2_http_simple_request_get_first_header
+ (simple_request, env, AXIS2_HTTP_HEADER_SOAP_ACTION), env);
soap_action_str = axutil_string_create(env, soap_action);
}
- if (0 == axutil_strcasecmp(axis2_http_request_line_get_method(
- axis2_http_simple_request_get_request_line(
- simple_request, env), env), AXIS2_HTTP_GET))
+ if (0 ==
+ axutil_strcasecmp(axis2_http_request_line_get_method
+ (axis2_http_simple_request_get_request_line
+ (simple_request, env), env), AXIS2_HTTP_GET))
{
processed = axis2_http_transport_utils_process_http_get_request
- (env, msg_ctx, request_body, out_stream,
- axis2_http_simple_request_get_content_type(
- simple_request, env) , soap_action_str,
- axutil_url_to_external_form(request_url, env),
- conf_ctx,
- axis2_http_transport_utils_get_request_params(env,
- axis2_http_request_line_get_uri(
- axis2_http_simple_request_get_request_line(
- simple_request, env), env)));
+ (env, msg_ctx, request_body, out_stream,
+ axis2_http_simple_request_get_content_type(simple_request, env),
+ soap_action_str, axutil_url_to_external_form(request_url, env),
+ conf_ctx, axis2_http_transport_utils_get_request_params(env,
+ axis2_http_request_line_get_uri
+ (axis2_http_simple_request_get_request_line
+ (simple_request,
+ env),
+ env)));
if (AXIS2_FALSE == processed)
{
axis2_http_header_t *cont_len = NULL;
@@ -266,47 +271,53 @@
axis2_char_t *body_string = NULL;
axis2_char_t *wsdl = NULL;
axis2_http_simple_response_set_status_line(response, env,
- http_version, AXIS2_HTTP_RESPONSE_OK_CODE_VAL, "OK");
- wsdl = strstr (url_external_form, AXIS2_REQUEST_WSDL);
+ http_version,
+ AXIS2_HTTP_RESPONSE_OK_CODE_VAL,
+ "OK");
+ wsdl = strstr(url_external_form, AXIS2_REQUEST_WSDL);
if (wsdl)
{
- body_string = axis2_http_transport_utils_get_services_static_wsdl(
- env, conf_ctx, url_external_form);
+ body_string =
+ axis2_http_transport_utils_get_services_static_wsdl(env,
+ conf_ctx,
+ url_external_form);
}
else
{
body_string = axis2_http_transport_utils_get_services_html(env,
- conf_ctx);
+ conf_ctx);
}
if (body_string)
{
axis2_char_t str_len[10];
axis2_http_simple_response_set_body_string(response, env,
- body_string);
+ body_string);
sprintf(str_len, "%d", axutil_strlen(body_string));
cont_len = axis2_http_header_create(env,
- AXIS2_HTTP_HEADER_CONTENT_LENGTH, str_len);
+ AXIS2_HTTP_HEADER_CONTENT_LENGTH,
+ str_len);
axis2_http_simple_response_set_header(response, env, cont_len);
cont_type = axis2_http_header_create(env,
- AXIS2_HTTP_HEADER_CONTENT_TYPE, AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML);
+ AXIS2_HTTP_HEADER_CONTENT_TYPE,
+ AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML);
axis2_http_simple_response_set_header(response, env, cont_type);
- }
- axis2_http_worker_set_response_headers(http_worker, env, svr_conn,
- simple_request, response, 0);
- axis2_simple_http_svr_conn_write_response(svr_conn, env, response);
- axis2_http_simple_response_free(response, env);
- return AXIS2_TRUE;
+ }
+ axis2_http_worker_set_response_headers(http_worker, env, svr_conn,
+ simple_request, response, 0);
+ axis2_simple_http_svr_conn_write_response(svr_conn, env, response);
+ axis2_http_simple_response_free(response, env);
+ return AXIS2_TRUE;
}
}
- else if (0 == axutil_strcasecmp(axis2_http_request_line_get_method(
- axis2_http_simple_request_get_request_line(
- simple_request, env), env), AXIS2_HTTP_POST))
+ else if (0 ==
+ axutil_strcasecmp(axis2_http_request_line_get_method
+ (axis2_http_simple_request_get_request_line
+ (simple_request, env), env), AXIS2_HTTP_POST))
{
status = axis2_http_transport_utils_process_http_post_request
- (env, msg_ctx, request_body, out_stream,
- axis2_http_simple_request_get_content_type(
- simple_request, env) , content_length, soap_action_str,
- url_external_form);
+ (env, msg_ctx, request_body, out_stream,
+ axis2_http_simple_request_get_content_type(simple_request, env),
+ content_length, soap_action_str, url_external_form);
if (status == AXIS2_FAILURE)
{
axis2_msg_ctx_t *fault_ctx = NULL;
@@ -317,46 +328,50 @@
axutil_property_t *http_error_property = NULL;
axis2_char_t *http_error_value = NULL;
axis2_char_t *fault_code = NULL;
- if (! engine)
+ if (!engine)
{
return AXIS2_FALSE;
}
- http_error_property = axis2_msg_ctx_get_property(msg_ctx, env,
- AXIS2_HTTP_TRANSPORT_ERROR);
+ http_error_property = axis2_msg_ctx_get_property(msg_ctx, env,
+ AXIS2_HTTP_TRANSPORT_ERROR);
if (http_error_property)
- http_error_value = (axis2_char_t *)axutil_property_get_value(
- http_error_property, env);
+ http_error_value =
+ (axis2_char_t *)
+ axutil_property_get_value(http_error_property, env);
- if ( axis2_msg_ctx_get_is_soap_11 (msg_ctx, env))
+ if (axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
{
- fault_code = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
+ fault_code = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
AXIOM_SOAP11_FAULT_CODE_SENDER;
}
else
{
- fault_code = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
+ fault_code = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
AXIOM_SOAP12_SOAP_FAULT_VALUE_SENDER;
}
- fault_ctx = axis2_engine_create_fault_msg_ctx(engine, env, msg_ctx,
- fault_code, axutil_error_get_message(env->error));
- req_line = axis2_http_simple_request_get_request_line(simple_request
- , env);
+ fault_ctx = axis2_engine_create_fault_msg_ctx(engine, env, msg_ctx,
+ fault_code,
+ axutil_error_get_message
+ (env->error));
+ req_line =
+ axis2_http_simple_request_get_request_line(simple_request, env);
if (req_line)
{
if (!http_error_value)
{
sprintf(status_line_str, "%s 500 Internal Server Error\r\n",
axis2_http_request_line_get_http_version(req_line,
- env));
+ env));
}
else
{
sprintf(status_line_str, "%s %s",
- axis2_http_request_line_get_http_version(req_line,env),
- http_error_value);
+ axis2_http_request_line_get_http_version(req_line,
+ env),
+ http_error_value);
}
}
else
@@ -365,56 +380,63 @@
\r\n");
}
- tmp_stat_line = axis2_http_status_line_create(env,
- status_line_str);
+ tmp_stat_line = axis2_http_status_line_create(env, status_line_str);
if (!http_error_value)
axis2_engine_send_fault(engine, env, fault_ctx);
axis2_http_simple_response_set_status_line(response, env,
- axis2_http_status_line_get_http_version(tmp_stat_line, env),
- axis2_http_status_line_get_status_code(tmp_stat_line, env) ,
- axis2_http_status_line_get_reason_phrase(tmp_stat_line, env));
+ axis2_http_status_line_get_http_version
+ (tmp_stat_line, env),
+ axis2_http_status_line_get_status_code
+ (tmp_stat_line, env),
+ axis2_http_status_line_get_reason_phrase
+ (tmp_stat_line, env));
axis2_http_simple_response_set_body_stream(response, env,
- out_stream);
+ out_stream);
axis2_http_worker_set_response_headers(http_worker, env, svr_conn,
- simple_request, response, axutil_stream_get_len(
- out_stream, env));
+ simple_request, response,
+ axutil_stream_get_len
+ (out_stream, env));
status = axis2_simple_http_svr_conn_write_response(svr_conn, env,
- response);
+ response);
return status;
}
}
- op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
if (axis2_op_ctx_get_response_written(op_ctx, env))
{
axis2_http_simple_response_set_status_line(response, env, http_version,
- AXIS2_HTTP_RESPONSE_OK_CODE_VAL, "OK");
+ AXIS2_HTTP_RESPONSE_OK_CODE_VAL,
+ "OK");
axis2_http_simple_response_set_body_stream(response, env, out_stream);
}
else
{
axis2_http_simple_response_set_status_line(response, env, http_version,
- AXIS2_HTTP_RESPONSE_ACK_CODE_VAL, "Accepted");
+ AXIS2_HTTP_RESPONSE_ACK_CODE_VAL,
+ "Accepted");
}
axis2_http_worker_set_response_headers(http_worker, env, svr_conn,
- simple_request, response, axutil_stream_get_len(
- out_stream, env));
+ simple_request, response,
+ axutil_stream_get_len(out_stream,
+ env));
status = axis2_simple_http_svr_conn_write_response(svr_conn, env, response);
AXIS2_FREE(env->allocator, url_external_form);
url_external_form = NULL;
- op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
- if (op_ctx)
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ if (op_ctx)
{
- axis2_msg_ctx_t *out_msg_ctx = NULL, *in_msg_ctx = NULL;
+ axis2_msg_ctx_t *out_msg_ctx = NULL,
+ *in_msg_ctx = NULL;
axis2_msg_ctx_t **msg_ctx_map = NULL;
axis2_char_t *msg_id = NULL;
axis2_conf_ctx_t *conf_ctx = NULL;
- msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
+ msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];
@@ -428,15 +450,16 @@
if (in_msg_ctx)
{
- msg_id = axutil_strdup(env, axis2_msg_ctx_get_msg_id(in_msg_ctx, env));
+ msg_id =
+ axutil_strdup(env, axis2_msg_ctx_get_msg_id(in_msg_ctx, env));
conf_ctx = axis2_msg_ctx_get_conf_ctx(in_msg_ctx, env);
-
+
axis2_msg_ctx_free(in_msg_ctx, env);
in_msg_ctx = NULL;
msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN] = NULL;
}
- if(!axis2_op_ctx_is_in_use(op_ctx, env))
+ if (!axis2_op_ctx_is_in_use(op_ctx, env))
{
axis2_op_ctx_destroy_mutex(op_ctx, env);
if (conf_ctx && msg_id)
@@ -446,9 +469,9 @@
}
axis2_op_ctx_free(op_ctx, env);
}
-
- } /* Done freeing message contexts */
-
+
+ } /* Done freeing message contexts */
+
msg_ctx = NULL;
axutil_url_free(request_url, env);
axutil_string_free(soap_action_str, env);
@@ -456,13 +479,13 @@
return status;
}
-static axis2_status_t
+static axis2_status_t
axis2_http_worker_set_response_headers(
- axis2_http_worker_t *http_worker,
- const axutil_env_t *env,
- axis2_simple_http_svr_conn_t *svr_conn,
- axis2_http_simple_request_t *simple_request,
- axis2_http_simple_response_t *simple_response,
+ axis2_http_worker_t * http_worker,
+ const axutil_env_t * env,
+ axis2_simple_http_svr_conn_t * svr_conn,
+ axis2_http_simple_request_t * simple_request,
+ axis2_http_simple_response_t * simple_response,
axis2_ssize_t content_length)
{
axis2_http_header_t *conn_header = NULL;
@@ -472,54 +495,58 @@
AXIS2_PARAM_CHECK(env->error, simple_request, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, simple_response, AXIS2_FAILURE);
if (AXIS2_FALSE == axis2_http_simple_response_contains_header
- (simple_response, env, AXIS2_HTTP_HEADER_CONNECTION))
+ (simple_response, env, AXIS2_HTTP_HEADER_CONNECTION))
{
conn_header = axis2_http_simple_request_get_first_header(simple_request,
- env, AXIS2_HTTP_HEADER_CONNECTION);
+ env,
+ AXIS2_HTTP_HEADER_CONNECTION);
if (conn_header)
{
if (0 == axutil_strcasecmp(axis2_http_header_get_value(conn_header,
- env), AXIS2_HTTP_HEADER_CONNECTION_KEEPALIVE))
+ env),
+ AXIS2_HTTP_HEADER_CONNECTION_KEEPALIVE))
{
axis2_http_header_t *header = axis2_http_header_create(env,
- AXIS2_HTTP_HEADER_CONNECTION,
- AXIS2_HTTP_HEADER_CONNECTION_KEEPALIVE);
+ AXIS2_HTTP_HEADER_CONNECTION,
+ AXIS2_HTTP_HEADER_CONNECTION_KEEPALIVE);
axis2_http_simple_response_set_header(simple_response, env,
- header);
+ header);
axis2_simple_http_svr_conn_set_keep_alive(svr_conn, env,
- AXIS2_TRUE);
+ AXIS2_TRUE);
}
if (0 == axutil_strcasecmp(axis2_http_header_get_value(conn_header,
- env), AXIS2_HTTP_HEADER_CONNECTION_CLOSE))
+ env),
+ AXIS2_HTTP_HEADER_CONNECTION_CLOSE))
{
axis2_http_header_t *header = axis2_http_header_create(env,
- AXIS2_HTTP_HEADER_CONNECTION,
- AXIS2_HTTP_HEADER_CONNECTION_CLOSE);
+ AXIS2_HTTP_HEADER_CONNECTION,
+ AXIS2_HTTP_HEADER_CONNECTION_CLOSE);
axis2_http_simple_response_set_header(simple_response, env,
- header);
+ header);
axis2_simple_http_svr_conn_set_keep_alive(svr_conn, env,
- AXIS2_FALSE);
+ AXIS2_FALSE);
}
}
else
{
- if (axis2_http_simple_response_get_http_version(simple_response, env)
- && axutil_strcasecmp(
- axis2_http_simple_response_get_http_version(
- simple_response, env), AXIS2_HTTP_HEADER_PROTOCOL_11))
+ if (axis2_http_simple_response_get_http_version
+ (simple_response, env) &&
+ axutil_strcasecmp(axis2_http_simple_response_get_http_version
+ (simple_response, env),
+ AXIS2_HTTP_HEADER_PROTOCOL_11))
{
axis2_simple_http_svr_conn_set_keep_alive(svr_conn, env,
- AXIS2_TRUE);
+ AXIS2_TRUE);
}
else
{
axis2_simple_http_svr_conn_set_keep_alive(svr_conn, env,
- AXIS2_FALSE);
+ AXIS2_FALSE);
}
}
- if (AXIS2_FALSE == axis2_http_simple_request_contains_header(
- simple_request, env,
- AXIS2_HTTP_HEADER_TRANSFER_ENCODING))
+ if (AXIS2_FALSE ==
+ axis2_http_simple_request_contains_header(simple_request, env,
+ AXIS2_HTTP_HEADER_TRANSFER_ENCODING))
{
if (0 != content_length)
{
@@ -527,19 +554,22 @@
axis2_http_header_t *content_len_hdr = NULL;
sprintf(content_len_str, "%d", content_length);
- content_len_hdr = axis2_http_header_create(
- env, AXIS2_HTTP_HEADER_CONTENT_LENGTH, content_len_str);
+ content_len_hdr =
+ axis2_http_header_create(env,
+ AXIS2_HTTP_HEADER_CONTENT_LENGTH,
+ content_len_str);
axis2_http_simple_response_set_header(simple_response, env,
- content_len_hdr);
+ content_len_hdr);
}
}
else
{
- axis2_http_header_t *transfer_enc_header = axis2_http_header_create(
- env, AXIS2_HTTP_HEADER_TRANSFER_ENCODING,
- AXIS2_HTTP_HEADER_TRANSFER_ENCODING_CHUNKED);
+ axis2_http_header_t *transfer_enc_header =
+ axis2_http_header_create(env,
+ AXIS2_HTTP_HEADER_TRANSFER_ENCODING,
+ AXIS2_HTTP_HEADER_TRANSFER_ENCODING_CHUNKED);
axis2_http_simple_response_set_header(simple_response, env,
- transfer_enc_header);
+ transfer_enc_header);
}
}
return AXIS2_SUCCESS;
@@ -549,12 +579,12 @@
* This is only called for HTTP/1.1 to enable 1.1 specific parameters.
*
*/
-static axis2_status_t
+static axis2_status_t
axis2_http_worker_set_transport_out_config(
- axis2_http_worker_t *http_worker,
- const axutil_env_t *env,
- axis2_conf_ctx_t *conf_ctx,
- axis2_http_simple_response_t *simple_response)
+ axis2_http_worker_t * http_worker,
+ const axutil_env_t * env,
+ axis2_conf_ctx_t * conf_ctx,
+ axis2_http_simple_response_t * simple_response)
{
axis2_conf_t *config = NULL;
@@ -562,16 +592,16 @@
AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, simple_response, AXIS2_FAILURE);
- config = axis2_conf_ctx_get_conf(conf_ctx, env);
+ config = axis2_conf_ctx_get_conf(conf_ctx, env);
return AXIS2_SUCCESS;
}
static axutil_hash_t *
axis2_http_worker_get_headers(
- axis2_http_worker_t *http_worker,
- const axutil_env_t *env,
- axis2_http_simple_request_t *request)
+ axis2_http_worker_t * http_worker,
+ const axutil_env_t * env,
+ axis2_http_simple_request_t * request)
{
axutil_array_list_t *header_list = NULL;
int hdr_count = 0;
@@ -608,15 +638,15 @@
}
}
axutil_hash_set(header_map, axis2_http_header_get_name(tmp_hdr, env),
- AXIS2_HASH_KEY_STRING, tmp_hdr);
+ AXIS2_HASH_KEY_STRING, tmp_hdr);
}
return header_map;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_http_worker_set_svr_port(
- axis2_http_worker_t *worker,
- const axutil_env_t *env,
+ axis2_http_worker_t * worker,
+ const axutil_env_t * env,
int port)
{
worker->svr_port = port;
Modified: webservices/axis2/trunk/c/src/core/transport/http/common/simple_http_svr_conn.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/common/simple_http_svr_conn.c?rev=580276&r1=580275&r2=580276&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/common/simple_http_svr_conn.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/common/simple_http_svr_conn.c Fri Sep 28 02:52:58 2007
@@ -1,3 +1,4 @@
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -32,16 +33,15 @@
AXIS2_EXTERN axis2_simple_http_svr_conn_t *AXIS2_CALL
axis2_simple_http_svr_conn_create(
- const axutil_env_t *env,
+ const axutil_env_t * env,
int sockfd)
{
axis2_simple_http_svr_conn_t *svr_conn = NULL;
AXIS2_ENV_CHECK(env, NULL);
svr_conn = (axis2_simple_http_svr_conn_t *)
- AXIS2_MALLOC(env->allocator,
- sizeof(axis2_simple_http_svr_conn_t));
+ AXIS2_MALLOC(env->allocator, sizeof(axis2_simple_http_svr_conn_t));
- if (! svr_conn)
+ if (!svr_conn)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return NULL;
@@ -52,12 +52,11 @@
if (-1 != svr_conn->socket)
{
- svr_conn->stream = axutil_stream_create_socket(env,
- svr_conn->socket);
- if (! svr_conn->stream)
+ svr_conn->stream = axutil_stream_create_socket(env, svr_conn->socket);
+ if (!svr_conn->stream)
{
axis2_simple_http_svr_conn_free((axis2_simple_http_svr_conn_t *)
- svr_conn, env);
+ svr_conn, env);
return NULL;
}
}
@@ -66,8 +65,8 @@
AXIS2_EXTERN void AXIS2_CALL
axis2_simple_http_svr_conn_free(
- axis2_simple_http_svr_conn_t *svr_conn,
- const axutil_env_t *env)
+ axis2_simple_http_svr_conn_t * svr_conn,
+ const axutil_env_t * env)
{
axis2_simple_http_svr_conn_close(svr_conn, env);
@@ -76,11 +75,10 @@
return;
}
-
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_simple_http_svr_conn_close(
- axis2_simple_http_svr_conn_t *svr_conn,
- const axutil_env_t *env)
+ axis2_simple_http_svr_conn_t * svr_conn,
+ const axutil_env_t * env)
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
@@ -93,11 +91,10 @@
return AXIS2_SUCCESS;
}
-
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_simple_http_svr_conn_is_open(
- axis2_simple_http_svr_conn_t *svr_conn,
- const axutil_env_t *env)
+ axis2_simple_http_svr_conn_t * svr_conn,
+ const axutil_env_t * env)
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
if (-1 != svr_conn->socket)
@@ -111,50 +108,44 @@
return AXIS2_FALSE;
}
-
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_simple_http_svr_conn_set_keep_alive(
- axis2_simple_http_svr_conn_t *svr_conn,
- const axutil_env_t *env,
+ axis2_simple_http_svr_conn_t * svr_conn,
+ const axutil_env_t * env,
axis2_bool_t keep_alive)
{
svr_conn->keep_alive = keep_alive;
return AXIS2_SUCCESS;
}
-
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_simple_http_svr_conn_is_keep_alive(
- axis2_simple_http_svr_conn_t *svr_conn,
- const axutil_env_t *env)
+ axis2_simple_http_svr_conn_t * svr_conn,
+ const axutil_env_t * env)
{
return svr_conn->keep_alive;
}
-
AXIS2_EXTERN axutil_stream_t *AXIS2_CALL
axis2_simple_http_svr_conn_get_stream(
- const axis2_simple_http_svr_conn_t *svr_conn,
- const axutil_env_t *env)
+ const axis2_simple_http_svr_conn_t * svr_conn,
+ const axutil_env_t * env)
{
return svr_conn->stream;
}
-
AXIS2_EXTERN axis2_http_response_writer_t *AXIS2_CALL
axis2_simple_http_svr_conn_get_writer(
- const axis2_simple_http_svr_conn_t *svr_conn,
- const axutil_env_t *env)
+ const axis2_simple_http_svr_conn_t * svr_conn,
+ const axutil_env_t * env)
{
- return axis2_http_response_writer_create(env,
- svr_conn->stream);
+ return axis2_http_response_writer_create(env, svr_conn->stream);
}
-
AXIS2_EXTERN axis2_http_simple_request_t *AXIS2_CALL
axis2_simple_http_svr_conn_read_request(
- axis2_simple_http_svr_conn_t *svr_conn,
- const axutil_env_t *env)
+ axis2_simple_http_svr_conn_t * svr_conn,
+ const axutil_env_t * env)
{
axis2_char_t str_line[2048];
axis2_char_t tmp_buf[2048];
@@ -167,7 +158,9 @@
AXIS2_ENV_CHECK(env, NULL);
memset(str_line, 0, 2048);
- while ((read = axutil_stream_peek_socket(svr_conn->stream, env, tmp_buf, 2048 - 1)) > 0)
+ while ((read =
+ axutil_stream_peek_socket(svr_conn->stream, env, tmp_buf,
+ 2048 - 1)) > 0)
{
axis2_char_t *start = tmp_buf;
axis2_char_t *end = NULL;
@@ -175,7 +168,9 @@
end = strstr(tmp_buf, AXIS2_HTTP_CRLF);
if (end)
{
- read = axutil_stream_read(svr_conn->stream, env, tmp_buf, end - start + 2);
+ read =
+ axutil_stream_read(svr_conn->stream, env, tmp_buf,
+ end - start + 2);
if (read > 0)
{
tmp_buf[read] = '\0';
@@ -197,11 +192,11 @@
}
}
}
-
+
if (strlen(str_line))
{
if (0 != axutil_strncasecmp(str_line, "GET", 3) && 0 !=
- axutil_strncasecmp(str_line, "POST", 4))
+ axutil_strncasecmp(str_line, "POST", 4))
{
char write_buf[512];
sprintf(write_buf, "%s %s\r\n%s: close\r\n\r\n",
@@ -209,26 +204,28 @@
AXIS2_HTTP_RESPONSE_BAD_REQUEST,
AXIS2_HTTP_HEADER_CONNECTION);
axutil_stream_write(svr_conn->stream, env, write_buf,
- axutil_strlen(write_buf) + 1);
+ axutil_strlen(write_buf) + 1);
return NULL;
}
}
request_line = axis2_http_request_line_parse_line(env, str_line);
- if (! request_line)
+ if (!request_line)
{
AXIS2_ERROR_SET(env->error,
- AXIS2_ERROR_INVALID_HTTP_HEADER_START_LINE,
- AXIS2_FAILURE);
+ AXIS2_ERROR_INVALID_HTTP_HEADER_START_LINE,
+ AXIS2_FAILURE);
return NULL;
}
- request = axis2_http_simple_request_create(env, request_line, NULL , 0,
- svr_conn->stream);
+ request = axis2_http_simple_request_create(env, request_line, NULL, 0,
+ svr_conn->stream);
/* now read the headers */
memset(str_line, 0, 2048);
end_of_line = AXIS2_FALSE;
while (AXIS2_FALSE == end_of_headers)
{
- while ((read = axutil_stream_peek_socket(svr_conn->stream, env, tmp_buf, 2048 - 1)) > 0)
+ while ((read =
+ axutil_stream_peek_socket(svr_conn->stream, env, tmp_buf,
+ 2048 - 1)) > 0)
{
axis2_char_t *start = tmp_buf;
axis2_char_t *end = NULL;
@@ -236,7 +233,9 @@
end = strstr(tmp_buf, AXIS2_HTTP_CRLF);
if (end)
{
- read = axutil_stream_read(svr_conn->stream, env, tmp_buf, end - start + 2);
+ read =
+ axutil_stream_read(svr_conn->stream, env, tmp_buf,
+ end - start + 2);
if (read > 0)
{
tmp_buf[read] = '\0';
@@ -251,14 +250,16 @@
}
else
{
- read = axutil_stream_read(svr_conn->stream, env, tmp_buf, 2048 - 1);
+ read =
+ axutil_stream_read(svr_conn->stream, env, tmp_buf,
+ 2048 - 1);
if (read > 0)
{
tmp_buf[read] = '\0';
strcat(str_line, tmp_buf);
}
}
-
+
}
if (AXIS2_TRUE == end_of_line)
@@ -275,7 +276,7 @@
if (tmp_header)
{
axis2_http_simple_request_add_header(request, env,
- tmp_header);
+ tmp_header);
}
}
}
@@ -284,12 +285,11 @@
return request;
}
-
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_simple_http_svr_conn_write_response(
- axis2_simple_http_svr_conn_t *svr_conn,
- const axutil_env_t *env,
- axis2_http_simple_response_t *response)
+ axis2_simple_http_svr_conn_t * svr_conn,
+ const axutil_env_t * env,
+ axis2_http_simple_response_t * response)
{
axis2_http_response_writer_t *response_writer = NULL;
axutil_array_list_t *headers = NULL;
@@ -303,51 +303,51 @@
axis2_bool_t binary_content = AXIS2_FALSE;
axis2_char_t *content_type = NULL;
-
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, response, AXIS2_FAILURE);
- response_writer = axis2_http_response_writer_create(env,
- svr_conn->stream);
- content_type = (axis2_char_t *)axis2_http_simple_response_get_content_type(
- response, env);
+ response_writer = axis2_http_response_writer_create(env, svr_conn->stream);
+ content_type =
+ (axis2_char_t *) axis2_http_simple_response_get_content_type(response,
+ env);
if (content_type)
{
if (strstr(content_type, AXIS2_HTTP_HEADER_ACCEPT_MULTIPART_RELATED)
- && strstr(content_type, AXIS2_HTTP_HEADER_XOP_XML))
+ && strstr(content_type, AXIS2_HTTP_HEADER_XOP_XML))
binary_content = AXIS2_TRUE;
}
- if (! response_writer)
+ if (!response_writer)
{
return AXIS2_FAILURE;
}
enc_header = axis2_http_simple_response_get_first_header(response, env,
- AXIS2_HTTP_HEADER_TRANSFER_ENCODING);
+ AXIS2_HTTP_HEADER_TRANSFER_ENCODING);
if (enc_header)
{
axis2_char_t *enc_value = axis2_http_header_get_value(enc_header, env);
if (enc_value)
{
if (0 == axutil_strcmp(enc_value,
- AXIS2_HTTP_HEADER_TRANSFER_ENCODING_CHUNKED))
+ AXIS2_HTTP_HEADER_TRANSFER_ENCODING_CHUNKED))
{
chuked_encoding = AXIS2_TRUE;
/* remove the content length header */
- if (AXIS2_TRUE == axis2_http_simple_response_contains_header(
- response, env, AXIS2_HTTP_HEADER_CONTENT_LENGTH))
+ if (AXIS2_TRUE ==
+ axis2_http_simple_response_contains_header(response, env,
+ AXIS2_HTTP_HEADER_CONTENT_LENGTH))
{
axis2_http_simple_response_remove_headers(response, env,
- AXIS2_HTTP_HEADER_CONTENT_LENGTH);
+ AXIS2_HTTP_HEADER_CONTENT_LENGTH);
}
}
}
}
status_line = axis2_http_simple_response_get_status_line(response, env);
- if (! status_line)
+ if (!status_line)
{
AXIS2_ERROR_SET(env->error,
- AXIS2_ERROR_INVALID_HTTP_HEADER_START_LINE,
- AXIS2_FAILURE);
+ AXIS2_ERROR_INVALID_HTTP_HEADER_START_LINE,
+ AXIS2_FAILURE);
axis2_http_response_writer_free(response_writer, env);
response_writer = NULL;
return AXIS2_FAILURE;
@@ -360,15 +360,15 @@
for (i = 0; i < axutil_array_list_size(headers, env); i++)
{
axis2_http_header_t *header = NULL;
- header = (axis2_http_header_t *)axutil_array_list_get(headers, env,
- i);
+ header = (axis2_http_header_t *) axutil_array_list_get(headers, env,
+ i);
if (header)
{
axis2_char_t *header_ext_form =
- axis2_http_header_to_external_form(
- (axis2_http_header_t*)header, env);
+ axis2_http_header_to_external_form((axis2_http_header_t *)
+ header, env);
axis2_http_response_writer_print_str(response_writer, env,
- header_ext_form);
+ header_ext_form);
AXIS2_FREE(env->allocator, header_ext_form);
}
}
@@ -394,17 +394,20 @@
axis2_status_t write_stat = AXIS2_FAILURE;
if (AXIS2_FALSE == binary_content)
write_stat = axis2_http_response_writer_println_str(response_writer,
- env, response_body);
+ env,
+ response_body);
else
{
write_stat = axis2_http_response_writer_write_buf(response_writer,
- env, response_body, 0, body_size);
+ env,
+ response_body, 0,
+ body_size);
}
if (AXIS2_SUCCESS != write_stat)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_WRITING_RESPONSE,
- AXIS2_FAILURE);
+ AXIS2_FAILURE);
axis2_http_response_writer_free(response_writer, env);
return AXIS2_FAILURE;
}
@@ -414,56 +417,54 @@
axis2_http_chunked_stream_t *chunked_stream = NULL;
int left = body_size;
chunked_stream = axis2_http_chunked_stream_create(env,
- svr_conn->stream);
+ svr_conn->stream);
while (left > 0)
{
left -= axis2_http_chunked_stream_write(chunked_stream, env,
- response_body, body_size);
+ response_body, body_size);
}
axis2_http_chunked_stream_write_last_chunk(chunked_stream, env);
axis2_http_chunked_stream_free(chunked_stream, env);
}
- /*AXIS2_FREE(env->allocator, response_body);*/
+ /*AXIS2_FREE(env->allocator, response_body); */
axis2_http_response_writer_free(response_writer, env);
return AXIS2_SUCCESS;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_simple_http_svr_conn_set_rcv_timeout(
- axis2_simple_http_svr_conn_t *svr_conn,
- const axutil_env_t *env,
+ axis2_simple_http_svr_conn_t * svr_conn,
+ const axutil_env_t * env,
int timeout)
{
return axutil_network_handler_set_sock_option(env,
- svr_conn->socket, SO_RCVTIMEO,
- timeout);
+ svr_conn->socket, SO_RCVTIMEO,
+ timeout);
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_simple_http_svr_conn_set_snd_timeout(
- axis2_simple_http_svr_conn_t *svr_conn,
- const axutil_env_t *env,
+ axis2_simple_http_svr_conn_t * svr_conn,
+ const axutil_env_t * env,
int timeout)
{
return axutil_network_handler_set_sock_option(env,
- svr_conn->socket, SO_SNDTIMEO,
- timeout);
+ svr_conn->socket, SO_SNDTIMEO,
+ timeout);
}
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_simple_http_svr_conn_get_svr_ip(
- const axis2_simple_http_svr_conn_t *svr_conn,
- const axutil_env_t *env)
+ const axis2_simple_http_svr_conn_t * svr_conn,
+ const axutil_env_t * env)
{
- return axutil_network_handler_get_svr_ip(env,
- svr_conn->socket);
+ return axutil_network_handler_get_svr_ip(env, svr_conn->socket);
}
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_simple_http_svr_conn_get_peer_ip(
- const axis2_simple_http_svr_conn_t *svr_conn,
- const axutil_env_t *env)
+ const axis2_simple_http_svr_conn_t * svr_conn,
+ const axutil_env_t * env)
{
- return axutil_network_handler_get_peer_ip(env,
- svr_conn->socket);
+ return axutil_network_handler_get_peer_ip(env, svr_conn->socket);
}
Modified: webservices/axis2/trunk/c/src/core/transport/http/receiver/http_receiver.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/receiver/http_receiver.c?rev=580276&r1=580275&r2=580276&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/receiver/http_receiver.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/receiver/http_receiver.c Fri Sep 28 02:52:58 2007
@@ -1,3 +1,4 @@
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -35,8 +36,8 @@
axis2_transport_receiver_t http_server;
axis2_http_svr_thread_t *svr_thread;
int port;
- axis2_conf_ctx_t* conf_ctx;
- axis2_conf_ctx_t* conf_ctx_private;
+ axis2_conf_ctx_t *conf_ctx;
+ axis2_conf_ctx_t *conf_ctx_private;
}
axis2_http_server_impl_t;
@@ -45,43 +46,36 @@
/***************************** Function headers *******************************/
-axis2_status_t AXIS2_CALL
-axis2_http_server_init(
- axis2_transport_receiver_t *server,
- const axutil_env_t *env,
- axis2_conf_ctx_t *conf_ctx,
- axis2_transport_in_desc_t *in_desc);
-
-axis2_status_t AXIS2_CALL
-axis2_http_server_start(
- axis2_transport_receiver_t *server,
- const axutil_env_t *env);
-
-axis2_status_t AXIS2_CALL
-axis2_http_server_stop(
- axis2_transport_receiver_t *server,
- const axutil_env_t *env);
-
-axis2_conf_ctx_t *AXIS2_CALL
-axis2_http_server_get_conf_ctx(
- axis2_transport_receiver_t *server,
- const axutil_env_t *env);
-
-axis2_endpoint_ref_t *AXIS2_CALL
-axis2_http_server_get_reply_to_epr(
- axis2_transport_receiver_t *server,
- const axutil_env_t *env,
- const axis2_char_t *svc_name);
-
-axis2_bool_t AXIS2_CALL
-axis2_http_server_is_running(
- axis2_transport_receiver_t *server,
- const axutil_env_t *env);
-
-void AXIS2_CALL
-axis2_http_server_free(
- axis2_transport_receiver_t *server,
- const axutil_env_t *env);
+axis2_status_t AXIS2_CALL axis2_http_server_init(
+ axis2_transport_receiver_t * server,
+ const axutil_env_t * env,
+ axis2_conf_ctx_t * conf_ctx,
+ axis2_transport_in_desc_t * in_desc);
+
+axis2_status_t AXIS2_CALL axis2_http_server_start(
+ axis2_transport_receiver_t * server,
+ const axutil_env_t * env);
+
+axis2_status_t AXIS2_CALL axis2_http_server_stop(
+ axis2_transport_receiver_t * server,
+ const axutil_env_t * env);
+
+axis2_conf_ctx_t *AXIS2_CALL axis2_http_server_get_conf_ctx(
+ axis2_transport_receiver_t * server,
+ const axutil_env_t * env);
+
+axis2_endpoint_ref_t *AXIS2_CALL axis2_http_server_get_reply_to_epr(
+ axis2_transport_receiver_t * server,
+ const axutil_env_t * env,
+ const axis2_char_t * svc_name);
+
+axis2_bool_t AXIS2_CALL axis2_http_server_is_running(
+ axis2_transport_receiver_t * server,
+ const axutil_env_t * env);
+
+void AXIS2_CALL axis2_http_server_free(
+ axis2_transport_receiver_t * server,
+ const axutil_env_t * env);
static const axis2_transport_receiver_ops_t http_transport_receiver_ops_var = {
axis2_http_server_init,
@@ -95,17 +89,17 @@
AXIS2_EXTERN axis2_transport_receiver_t *AXIS2_CALL
axis2_http_server_create(
- const axutil_env_t *env,
- const axis2_char_t *repo,
+ const axutil_env_t * env,
+ const axis2_char_t * repo,
const int port)
{
axis2_http_server_impl_t *server_impl = NULL;
AXIS2_ENV_CHECK(env, NULL);
- server_impl = (axis2_http_server_impl_t *)AXIS2_MALLOC
- (env->allocator, sizeof(axis2_http_server_impl_t));
+ server_impl = (axis2_http_server_impl_t *) AXIS2_MALLOC
+ (env->allocator, sizeof(axis2_http_server_impl_t));
- if (! server_impl)
+ if (!server_impl)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return NULL;
@@ -117,9 +111,10 @@
server_impl->port = port;
server_impl->http_server.ops = &http_transport_receiver_ops_var;
-
+
if (repo)
{
+
/**
* We first create a private conf ctx which is owned by this server
* we only free this private conf context. We should never free the
@@ -127,9 +122,10 @@
* may lead to double free
*/
server_impl->conf_ctx_private = axis2_build_conf_ctx(env, repo);
- if (! server_impl->conf_ctx_private)
+ if (!server_impl->conf_ctx_private)
{
- axis2_http_server_free((axis2_transport_receiver_t *) server_impl, env);
+ axis2_http_server_free((axis2_transport_receiver_t *) server_impl,
+ env);
return NULL;
}
server_impl->conf_ctx = server_impl->conf_ctx_private;
@@ -140,8 +136,8 @@
void AXIS2_CALL
axis2_http_server_free(
- axis2_transport_receiver_t *server,
- const axutil_env_t *env)
+ axis2_transport_receiver_t * server,
+ const axutil_env_t * env)
{
axis2_http_server_impl_t *server_impl = NULL;
AXIS2_ENV_CHECK(env, void);
@@ -155,9 +151,10 @@
if (server_impl->conf_ctx_private)
{
- axis2_conf_ctx_free(server_impl->conf_ctx_private, env);
+ axis2_conf_ctx_free(server_impl->conf_ctx_private, env);
server_impl->conf_ctx_private = NULL;
}
+
/**
* Do not free this. It may own to some other object
*/
@@ -167,13 +164,12 @@
return;
}
-
axis2_status_t AXIS2_CALL
axis2_http_server_init(
- axis2_transport_receiver_t *server,
- const axutil_env_t *env,
- axis2_conf_ctx_t *conf_ctx,
- axis2_transport_in_desc_t *in_desc)
+ axis2_transport_receiver_t * server,
+ const axutil_env_t * env,
+ axis2_conf_ctx_t * conf_ctx,
+ axis2_transport_in_desc_t * in_desc)
{
axis2_http_server_impl_t *server_impl = NULL;
axis2_char_t *port_str = NULL;
@@ -183,9 +179,10 @@
server_impl = AXIS2_INTF_TO_IMPL(server);
server_impl->conf_ctx = conf_ctx;
- param = (axutil_param_t *)axutil_param_container_get_param(
- axis2_transport_in_desc_param_container(in_desc, env),
- env, "port");
+ param =
+ (axutil_param_t *)
+ axutil_param_container_get_param(axis2_transport_in_desc_param_container
+ (in_desc, env), env, "port");
if (param)
{
port_str = axutil_param_get_value(param, env);
@@ -197,11 +194,10 @@
return AXIS2_SUCCESS;
}
-
axis2_status_t AXIS2_CALL
axis2_http_server_start(
- axis2_transport_receiver_t *server,
- const axutil_env_t *env)
+ axis2_transport_receiver_t * server,
+ const axutil_env_t * env)
{
axis2_http_server_impl_t *server_impl = NULL;
@@ -210,14 +206,14 @@
server_impl = AXIS2_INTF_TO_IMPL(server);
server_impl->svr_thread = axis2_http_svr_thread_create(env,
- server_impl->port);
- if (! server_impl->svr_thread)
+ server_impl->port);
+ if (!server_impl->svr_thread)
{
return AXIS2_FAILURE;
}
worker = axis2_http_worker_create(env, server_impl->conf_ctx);
axis2_http_worker_set_svr_port(worker, env, server_impl->port);
- if (! worker)
+ if (!worker)
{
axis2_http_svr_thread_free(server_impl->svr_thread, env);
return AXIS2_FAILURE;
@@ -228,11 +224,10 @@
return AXIS2_SUCCESS;
}
-
axis2_status_t AXIS2_CALL
axis2_http_server_stop(
- axis2_transport_receiver_t *server,
- const axutil_env_t *env)
+ axis2_transport_receiver_t * server,
+ const axutil_env_t * env)
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
@@ -240,17 +235,16 @@
if (AXIS2_INTF_TO_IMPL(server)->svr_thread)
{
axis2_http_svr_thread_destroy(AXIS2_INTF_TO_IMPL(server)->svr_thread,
- env);
+ env);
}
- AXIS2_LOG_INFO(env->log, "Successfully terminated HTTP server"
- " thread");
+ AXIS2_LOG_INFO(env->log, "Successfully terminated HTTP server" " thread");
return AXIS2_SUCCESS;
}
axis2_conf_ctx_t *AXIS2_CALL
axis2_http_server_get_conf_ctx(
- axis2_transport_receiver_t *server,
- const axutil_env_t *env)
+ axis2_transport_receiver_t * server,
+ const axutil_env_t * env)
{
AXIS2_ENV_CHECK(env, NULL);
return AXIS2_INTF_TO_IMPL(server)->conf_ctx;
@@ -258,9 +252,9 @@
axis2_endpoint_ref_t *AXIS2_CALL
axis2_http_server_get_reply_to_epr(
- axis2_transport_receiver_t *server,
- const axutil_env_t *env,
- const axis2_char_t *svc_name)
+ axis2_transport_receiver_t * server,
+ const axutil_env_t * env,
+ const axis2_char_t * svc_name)
{
axis2_endpoint_ref_t *epr = NULL;
const axis2_char_t *host_address = NULL;
@@ -272,9 +266,9 @@
host_address = "127.0.0.1"; /* TODO : get from axis2.xml */
svc_path = axutil_stracat(env, "/axis2/services/", svc_name);
url = axutil_url_create(env, "http", host_address,
- AXIS2_INTF_TO_IMPL(server)->port, svc_path);
+ AXIS2_INTF_TO_IMPL(server)->port, svc_path);
AXIS2_FREE(env->allocator, svc_path);
- if (! url)
+ if (!url)
{
return NULL;
}
@@ -285,13 +279,13 @@
axis2_bool_t AXIS2_CALL
axis2_http_server_is_running(
- axis2_transport_receiver_t *server,
- const axutil_env_t *env)
+ axis2_transport_receiver_t * server,
+ const axutil_env_t * env)
{
axis2_http_server_impl_t *server_impl = NULL;
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
server_impl = AXIS2_INTF_TO_IMPL(server);
- if (! server_impl->svr_thread)
+ if (!server_impl->svr_thread)
{
return AXIS2_FALSE;
}
@@ -305,9 +299,10 @@
/**
* Following block distinguish the exposed part of the dll.
*/
-AXIS2_EXPORT int axis2_get_instance(
+AXIS2_EXPORT int
+axis2_get_instance(
struct axis2_transport_receiver **inst,
- const axutil_env_t *env)
+ const axutil_env_t * env)
{
*inst = axis2_http_server_create(env, NULL, -1);
if (!(*inst))
@@ -318,9 +313,10 @@
return AXIS2_SUCCESS;
}
-AXIS2_EXPORT int axis2_remove_instance(
- axis2_transport_receiver_t *inst,
- const axutil_env_t *env)
+AXIS2_EXPORT int
+axis2_remove_instance(
+ axis2_transport_receiver_t * inst,
+ const axutil_env_t * env)
{
if (inst)
{
Modified: webservices/axis2/trunk/c/src/core/transport/http/receiver/http_svr_thread.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/receiver/http_svr_thread.c?rev=580276&r1=580275&r2=580276&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/receiver/http_svr_thread.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/receiver/http_svr_thread.c Fri Sep 28 02:52:58 2007
@@ -1,3 +1,4 @@
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -44,31 +45,27 @@
axis2_socket_t socket;
axis2_http_worker_t *worker;
axutil_thread_t *thread;
-}axis2_http_svr_thd_args_t;
-
+} axis2_http_svr_thd_args_t;
-AXIS2_EXTERN const axutil_env_t *AXIS2_CALL
-init_thread_env(
- const axutil_env_t **system_env);
+AXIS2_EXTERN const axutil_env_t *AXIS2_CALL init_thread_env(
+ const axutil_env_t ** system_env);
-void *AXIS2_THREAD_FUNC
-axis2_svr_thread_worker_func(
- axutil_thread_t *thd,
+void *AXIS2_THREAD_FUNC axis2_svr_thread_worker_func(
+ axutil_thread_t * thd,
void *data);
axis2_http_svr_thread_t *AXIS2_CALL
axis2_http_svr_thread_create(
- const axutil_env_t *env,
+ const axutil_env_t * env,
int port)
{
axis2_http_svr_thread_t *svr_thread = NULL;
AXIS2_ENV_CHECK(env, NULL);
- svr_thread = (axis2_http_svr_thread_t *)AXIS2_MALLOC
- (env->allocator, sizeof(
- axis2_http_svr_thread_t));
+ svr_thread = (axis2_http_svr_thread_t *) AXIS2_MALLOC
+ (env->allocator, sizeof(axis2_http_svr_thread_t));
- if (! svr_thread)
+ if (!svr_thread)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return NULL;
@@ -78,22 +75,20 @@
svr_thread->stopped = AXIS2_FALSE;
svr_thread->port = port;
svr_thread->listen_socket = axutil_network_handler_create_server_socket
- (env, svr_thread->port);
+ (env, svr_thread->port);
if (-1 == svr_thread->listen_socket)
{
- axis2_http_svr_thread_free((axis2_http_svr_thread_t *) svr_thread,
- env);
+ axis2_http_svr_thread_free((axis2_http_svr_thread_t *) svr_thread, env);
return NULL;
}
return svr_thread;
}
-
void AXIS2_CALL
axis2_http_svr_thread_free(
- axis2_http_svr_thread_t *svr_thread,
- const axutil_env_t *env)
+ axis2_http_svr_thread_t * svr_thread,
+ const axutil_env_t * env)
{
AXIS2_ENV_CHECK(env, void);
@@ -108,16 +103,15 @@
svr_thread->listen_socket = -1;
}
svr_thread->stopped = AXIS2_TRUE;
-
+
AXIS2_FREE(env->allocator, svr_thread);
return;
}
-
axis2_status_t AXIS2_CALL
axis2_http_svr_thread_run(
- axis2_http_svr_thread_t *svr_thread,
- const axutil_env_t *env)
+ axis2_http_svr_thread_t * svr_thread,
+ const axutil_env_t * env)
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
@@ -128,37 +122,39 @@
axutil_thread_t *worker_thread = NULL;
socket = axutil_network_handler_svr_socket_accept(env,
- svr_thread->listen_socket);
- if (! svr_thread->worker)
+ svr_thread->
+ listen_socket);
+ if (!svr_thread->worker)
{
AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "Worker not ready yet."
- " Cannot serve the request");
+ " Cannot serve the request");
axutil_network_handler_close_socket(env, socket);
continue;
}
arg_list = AXIS2_MALLOC(env->allocator,
- sizeof(axis2_http_svr_thd_args_t));
- if (! arg_list)
+ sizeof(axis2_http_svr_thd_args_t));
+ if (!arg_list)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Memory allocation error in the svr thread loop");
+ "Memory allocation error in the svr thread loop");
continue;
}
- arg_list->env = (axutil_env_t *)env;
+ arg_list->env = (axutil_env_t *) env;
arg_list->socket = socket;
arg_list->worker = svr_thread->worker;
#ifdef AXIS2_SVR_MULTI_THREADED
worker_thread = axutil_thread_pool_get_thread(env->thread_pool,
- axis2_svr_thread_worker_func, (void *)arg_list);
- if (! worker_thread)
+ axis2_svr_thread_worker_func,
+ (void *) arg_list);
+ if (!worker_thread)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Thread creation failed"
- "server thread loop");
+ "server thread loop");
continue;
}
axutil_thread_pool_thread_detach(env->thread_pool, worker_thread);
#else
- axis2_svr_thread_worker_func(NULL, (void *)arg_list);
+ axis2_svr_thread_worker_func(NULL, (void *) arg_list);
#endif
}
return AXIS2_SUCCESS;
@@ -166,8 +162,8 @@
axis2_status_t AXIS2_CALL
axis2_http_svr_thread_destroy(
- axis2_http_svr_thread_t *svr_thread,
- const axutil_env_t *env)
+ axis2_http_svr_thread_t * svr_thread,
+ const axutil_env_t * env)
{
AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
@@ -177,7 +173,7 @@
}
svr_thread->stopped = AXIS2_TRUE;
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Terminating HTTP server "
- "thread.");
+ "thread.");
if (svr_thread->listen_socket)
{
axutil_network_handler_close_socket(env, svr_thread->listen_socket);
@@ -188,25 +184,25 @@
int AXIS2_CALL
axis2_http_svr_thread_get_local_port(
- const axis2_http_svr_thread_t *svr_thread,
- const axutil_env_t *env)
+ const axis2_http_svr_thread_t * svr_thread,
+ const axutil_env_t * env)
{
return svr_thread->port;
}
axis2_bool_t AXIS2_CALL
axis2_http_svr_thread_is_running(
- axis2_http_svr_thread_t *svr_thread,
- const axutil_env_t *env)
+ axis2_http_svr_thread_t * svr_thread,
+ const axutil_env_t * env)
{
return svr_thread->port;
}
axis2_status_t AXIS2_CALL
axis2_http_svr_thread_set_worker(
- axis2_http_svr_thread_t *svr_thread,
- const axutil_env_t *env,
- axis2_http_worker_t *worker)
+ axis2_http_svr_thread_t * svr_thread,
+ const axutil_env_t * env,
+ axis2_http_worker_t * worker)
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, worker, AXIS2_FAILURE);
@@ -214,16 +210,16 @@
return AXIS2_SUCCESS;
}
-
/**
* Thread worker function.
*/
void *AXIS2_THREAD_FUNC
-axis2_svr_thread_worker_func (
- axutil_thread_t *thd,
+axis2_svr_thread_worker_func(
+ axutil_thread_t * thd,
void *data)
{
- struct AXIS2_PLATFORM_TIMEB t1, t2;
+ struct AXIS2_PLATFORM_TIMEB t1,
+ t2;
axis2_simple_http_svr_conn_t *svr_conn = NULL;
axis2_http_simple_request_t *request = NULL;
int millisecs = 0;
@@ -241,8 +237,8 @@
#endif
#endif
- arg_list = (axis2_http_svr_thd_args_t *)data;
- if (! arg_list)
+ arg_list = (axis2_http_svr_thd_args_t *) data;
+ if (!arg_list)
{
return NULL;
}
@@ -252,11 +248,11 @@
socket = arg_list->socket;
svr_conn = axis2_simple_http_svr_conn_create(thread_env, socket);
axis2_simple_http_svr_conn_set_rcv_timeout(svr_conn, thread_env,
- axis2_http_socket_read_timeout);
+ axis2_http_socket_read_timeout);
request = axis2_simple_http_svr_conn_read_request(svr_conn, thread_env);
tmp = arg_list->worker;
status = axis2_http_worker_process_request(tmp, thread_env, svr_conn,
- request);
+ request);
axis2_simple_http_svr_conn_free(svr_conn, thread_env);
if (request)
axis2_http_simple_request_free(request, thread_env);
@@ -282,11 +278,11 @@
{
#if defined(WIN32)
AXIS2_LOG_WARNING(thread_env->log, AXIS2_LOG_SI,
- "Error occured in processing request ");
+ "Error occured in processing request ");
#else
AXIS2_LOG_WARNING(thread_env->log, AXIS2_LOG_SI,
- "Error occured in processing request (%.3f seconds)",
- secs);
+ "Error occured in processing request (%.3f seconds)",
+ secs);
#endif
}
@@ -294,13 +290,12 @@
if (thread_env)
{
- /*axutil_free_thread_env(thread_env);*/
+ /*axutil_free_thread_env(thread_env); */
thread_env = NULL;
}
#ifdef AXIS2_SVR_MULTI_THREADED
- /*axutil_thread_pool_exit_thread(env->thread_pool, thd);*/
+ /*axutil_thread_pool_exit_thread(env->thread_pool, thd); */
#endif
return NULL;
}
-
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org