26
26
#include <http_protocol.h>
27
27
#include <http_log.h>
28
28
29
- #include "ngrest_server.h"
29
+ #include "../../share/ ngrest_server.h"
30
30
31
31
32
32
static const char * ngrestServicesPath = NULL ;
33
33
static int initialized = 0 ;
34
34
35
- #ifdef NGREST_APACHE2_MOD_DEBUG
35
+ #ifdef NGREST_MOD_DEBUG
36
36
FILE * logFile = NULL ;
37
37
#define LOGLABEL fprintf(logFile, "p%d t%d; %s[%d]: %s\n", \
38
38
getpid(), (int)pthread_self(), __FILE__, __LINE__, __FUNCTION__); fflush(logFile);
@@ -52,12 +52,12 @@ FILE* logFile = NULL;
52
52
53
53
#define INT_STR_LEN 16
54
54
55
- const char * mod_ngrest_iterate_request_headers (void * req , void * data , iterate_request_headers_callback callback )
55
+ static void mod_ngrest_iterate_request_headers (void * req , void * data , iterate_request_headers_callback callback )
56
56
{
57
57
apr_table_do (callback , data , ((request_rec * )req )-> headers_in , NULL );
58
58
}
59
59
60
- int64_t mod_ngrest_read_client_callback (void * req , char * buffer , int64_t size )
60
+ static int64_t mod_ngrest_read_client_callback (void * req , char * buffer , int64_t size )
61
61
{
62
62
int64_t res = ap_get_client_block (req , buffer , size );
63
63
LOG2 ("REMAINING: %ld / %ld" , ((request_rec * )req )-> remaining , ((request_rec * )req )-> read_length );
@@ -66,28 +66,40 @@ int64_t mod_ngrest_read_client_callback(void* req, char* buffer, int64_t size)
66
66
return res ;
67
67
}
68
68
69
- void mod_ngrest_set_response_header (void * req , const char * header , const char * value )
69
+ static void mod_ngrest_set_response_header (void * req , const char * header , const char * value )
70
70
{
71
71
apr_table_set (((request_rec * )req )-> headers_out , header , value );
72
72
}
73
73
74
- void mod_ngrest_set_content_type (void * req , const char * contentType )
74
+ static void mod_ngrest_set_content_type (void * req , const char * contentType )
75
75
{
76
76
((request_rec * )req )-> content_type = contentType ;
77
77
}
78
78
79
- int64_t mod_ngrest_write_client_callback (void * req , const void * buffer , int64_t size )
79
+ static void mod_ngrest_set_content_length (void * req , int64_t contentLength )
80
+ {
81
+ // apache2 ignores setting of Content-Length header
82
+ }
83
+
84
+ static int64_t mod_ngrest_write_client_callback (void * req , const void * buffer , int64_t size )
80
85
{
81
86
LOG1 ("response size: %ld" , size );
82
87
return ap_rwrite (buffer , size , req );
83
88
}
84
89
90
+ static void mod_ngrest_finalize_request (void * req , int status )
91
+ {
92
+ ((request_rec * )req )-> status = status ;
93
+ }
94
+
85
95
static struct ngrest_mod_callbacks mod_ngrest_server_callbacks = {
86
96
mod_ngrest_iterate_request_headers ,
87
97
mod_ngrest_read_client_callback ,
88
98
mod_ngrest_set_response_header ,
89
99
mod_ngrest_set_content_type ,
90
- mod_ngrest_write_client_callback
100
+ mod_ngrest_set_content_length ,
101
+ mod_ngrest_write_client_callback ,
102
+ mod_ngrest_finalize_request
91
103
};
92
104
93
105
/* content handler */
@@ -137,7 +149,7 @@ static int mod_ngrest_handler(request_rec* req)
137
149
req -> remaining
138
150
};
139
151
140
- req -> status = ngrest_server_dispatch (& request , mod_ngrest_server_callbacks );
152
+ ngrest_server_dispatch (& request , mod_ngrest_server_callbacks );
141
153
LOGLABEL ;
142
154
}
143
155
@@ -158,7 +170,7 @@ static apr_status_t mod_ngrest_shutdown(void* data)
158
170
159
171
static void ngrest_register_hooks (apr_pool_t * pool )
160
172
{
161
- #ifdef NGREST_APACHE2_MOD_DEBUG
173
+ #ifdef NGREST_MOD_DEBUG
162
174
char logPath [PATH_MAX ];
163
175
snprintf (logPath , PATH_MAX , "/tmp/ngrest_debug_%d.log" , getpid ());
164
176
logFile = fopen (logPath , "a" );
0 commit comments