42 #include "http_config.h"
43 #include "http_core.h"
45 #include "http_protocol.h"
46 #include "http_request.h"
47 #include "http_main.h"
48 #include "util_script.h"
54 char *
ltoa(
long val,
char *buf,
int base)
57 if (base > 36 || base < 2)
64 r = ldiv (labs(val), base);
67 buf =
ltoa ( r.quot, buf, base);
71 *buf++ =
"0123456789abcdefghijklmnopqrstuvwxyz"[(int)r.rem];
77 static int util_read(request_rec *r,
const char **rbuf)
81 if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)))
86 if (ap_should_client_block(r))
88 char argsbuffer[HUGE_STRING_LEN];
89 int rsize, len_read, rpos=0;
90 long length = r->remaining;
91 *rbuf = (
char*) ap_pcalloc(r->pool, length + 1);
93 ap_hard_timeout(
"util_read", r);
95 while((len_read = ap_get_client_block(r, argsbuffer,
sizeof(argsbuffer))) > 0)
98 if ((rpos + len_read) > length)
100 rsize = length - rpos;
106 memcpy((
char*)*rbuf + rpos, argsbuffer, rsize);
116 header_trace(
void *data,
const char *key,
const char *val )
118 request_rec *r = (request_rec *)data ;
119 cerr <<
"Header Field '" << key <<
"' = '" << val <<
"'" << endl ;
124 list_headers( request_rec *r )
126 ap_table_do( header_trace, r, r->headers_in, NULL ) ;
129 static int opendap_handler(request_rec *r)
131 char port_number_buffer[80];
132 dup2(r->connection->client->fd,STDOUT_FILENO);
149 ltoa(ap_get_server_port(r), port_number_buffer, 10);
153 rq.
user_agent = ap_table_get(r->headers_in,
"User-Agent");
155 const char* m_method = r->method;
158 cerr <<
"mod_opendap: Fatal, Cannot load request method" << endl;
163 if ( strcmp(m_method,
"GET") == 0 )
165 if(r->parsed_uri.query)
178 else if (strcmp(m_method,
"POST") == 0 )
180 const char *post_data=0;
181 util_read(r, &post_data);
200 rq.
cookie = ap_table_get( r->headers_in,
"Cookie" ) ;
205 while( rq.
request && status == 0 )
222 static handler_rec opendap_handlers[] =
224 {
"opendap-handler", opendap_handler},
231 STANDARD_MODULE_STUFF,