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 2003/07/24 08:53:24 UTC
cvs commit: xml-axis/c/src/server/apache mod_axis.c
sanjaya 2003/07/23 23:53:23
Modified: c/src/server/apache mod_axis.c
Log:
implemented new transport module api
Revision Changes Path
1.2 +87 -50 xml-axis/c/src/server/apache/mod_axis.c
Index: mod_axis.c
===================================================================
RCS file: /home/cvs/xml-axis/c/src/server/apache/mod_axis.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- mod_axis.c 25 Jun 2003 06:09:12 -0000 1.1
+++ mod_axis.c 24 Jul 2003 06:53:23 -0000 1.2
@@ -1,68 +1,101 @@
+/*
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_protocol.h"
+*/
+
+#include <apache/httpd.h>
+#include <apache/http_config.h>
+#include <apache/http_core.h>
+#include <apache/http_log.h>
+#include <apache/http_protocol.h>
+#include <apache/http_main.h>
#include "../../common/Packet.h"
#include <string.h>
#include <malloc.h>
+#define xxx ap_log_rerror(APLOG_MARK,APLOG_ERR, globr,"logged here");
+#define yyy ap_log_rerror(APLOG_MARK, APLOG_ERR, globr,"logged here");
+
+
/* file: mod_axis.c */
/* here's the content handler */
-extern int process(soapstream *);
+extern int process_request(soapstream *);
+//extern int process(soapstream *);
extern unsigned char chEBuf[1024];
+//global place holder for the current request_record
+request_rec * globr;
+//global variable to store the nubmer of bytes read from ap_get_client_block
+int len_read = 0;
+//global variable to store the remaining number of bytes to be read from the http request content
+int cont_length_remaining=0;
+
+//Should dispatch the headers from within this method
+int send_transport_information(soapstream * hdr)
+{
+ ap_send_http_header(globr);
+ return 0;
+}
+
+//Call initialize_module() [of Packet.h] from within this method
+void module_init(server_rec *r, pool* p)
+{}
+
+int send_response_bytes(char * res)
+{
+ ap_rputs(res, globr);
+ return 0;
+}
+
+//Cal initialize_process() [of Packet.h] from within this method
+void axis_Init(server_rec *r, pool* p)
+{}
+//Call finalize_process() [of Packet.h] from within this method
+void axis_Fini(server_rec *r, pool* p)
+{}
+
+int get_request_bytes(char * req, int reqsize, int* retsize)
+{
+
+ if(cont_length_remaining>0)
+ {
+ ap_hard_timeout("util_read", globr);
+ len_read = ap_get_client_block(globr, req, reqsize);
+
+ ap_reset_timeout(globr);
+ cont_length_remaining -= len_read;
+ *retsize = len_read;
+ }
+ else
+ {
+ *retsize = 0;
+ }
+ return 0;
+}
+
static int axis_handler(request_rec *r)
{
+
+ int rc;
char argsbuffer[HUGE_STRING_LEN];
+ soapstream * sstr;
+ array_header * arr;
+ globr = r;
memset(argsbuffer,0,HUGE_STRING_LEN);
- int rc;
- soapstream * sstr = malloc(sizeof(soapstream));
+ sstr = malloc(sizeof(soapstream));
sstr->trtype=APTHTTP;
-
r->content_type = "text/html";
- ap_send_http_header(r);
-
-
- //TODO
- //if the request is a GET request handle it
-
//set up the read policy from the client.
if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)) != OK)
{
return rc;
}
-
- //tell the client that we are ready to receive content and check whether client will send content
- //control will pass to this block only if there is body content in the request
- if (ap_should_client_block(r))
- {
- int rsize, len_read, rpos=0;
- long length = r->remaining;
- //set the byte count of the body content, in the axis soap data structure
- sstr->so.http.ip_soapcount=r->remaining;
- ap_hard_timeout("util_read", r);
- while ((len_read = ap_get_client_block(r, argsbuffer, sizeof(argsbuffer))) > 0)
- {
- ap_reset_timeout(r);
- if ((rpos + len_read) > length)
- {
- rsize = length - rpos;
- }
- else
- {
- rsize = len_read;
- }
- }
- ap_kill_timeout(r);
- }
-
- //assign the body content, to the axis soap data structure
- sstr->so.http.ip_soap= argsbuffer;
-
//ap_table_elts returns an array_header struct. The nelts element of that struct contains the number of
//input header elements. Finally assigns that to the axis soap data structure.
sstr->so.http.ip_headercount = ap_table_elts(r->headers_in)->nelts;
@@ -70,7 +103,7 @@
//casting r->headers_in to axis header struct and assigning that to the axis soap structure. Hope this is ok
//obtain the array_header from the headers_in table and assign it to the axis soap structure
- array_header * arr = ap_table_elts(r->headers_in);
+ arr = ap_table_elts(r->headers_in);
sstr->so.http.ip_headers = (header *)arr->elts;
//Determine the http method and assign it to the axis soap structure
@@ -85,17 +118,21 @@
default:
sstr->so.http.ip_method = UNSUPPORTED;
}
-
- if(0 == process(sstr))
- {
- ap_rputs(sstr->so.http.op_soap, r);
- //free(sstr->so.http.op_soap);
- }
- else
+
+ //tell the client that we are ready to receive content and check whether client will send content
+ //control will pass to this block only if there is body content in the request
+ if (ap_should_client_block(globr));
+ cont_length_remaining = r->remaining;
+
+ if(0 != process_request(sstr))
{
- ap_rputs("SOAP Engined failed to response",r);
+ ap_rputs("SOAP Engine failed to response",r);
+ return OK;
}
+
+
free(sstr);
+ //free(arr);
return OK;
}
/* Make the name of the content handler known to Apache */
@@ -108,7 +145,7 @@
module MODULE_VAR_EXPORT axis_module =
{
STANDARD_MODULE_STUFF,
- NULL, /* module initializer */
+ module_init, /* module initializer */
NULL, /* per-directory config creator */
NULL, /* dir config merger */
NULL, /* server config creator */
@@ -123,7 +160,7 @@
NULL, /* [8] fixups */
NULL, /* [10] logger */
NULL, /* [3] header parser */
- NULL, /* process initialization */
- NULL, /* process exit/cleanup */
+ axis_Init, /* process initialization */
+ axis_Fini, /* process exit/cleanup */
NULL /* [1] post read_request handling */
};