MCPcopy Create free account
hub / github.com/apache/httpd / log_before

Function log_before

modules/loggers/mod_log_forensic.c:182–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182static int log_before(request_rec *r)
183{
184 fcfg *cfg = ap_get_module_config(r->server->module_config,
185 &log_forensic_module);
186 const char *id;
187 hlog h;
188 apr_size_t n;
189 apr_status_t rv;
190
191 if (!cfg->fd || r->prev) {
192 return DECLINED;
193 }
194
195 if (!(id = apr_table_get(r->subprocess_env, "UNIQUE_ID"))) {
196 /* we make the assumption that we can't go through all the PIDs in
197 under 1 second */
198 id = apr_psprintf(r->pool, "%" APR_PID_T_FMT ":%lx:%x", getpid(),
199 time(NULL), apr_atomic_inc32(&next_id));
200 }
201 ap_set_module_config(r->request_config, &log_forensic_module, (char *)id);
202
203 h.p = r->pool;
204 h.count = 0;
205
206 apr_table_do(count_headers, &h, r->headers_in, NULL);
207
208 h.count += 1+strlen(id)+1+count_string(r->the_request)+1+1;
209 h.log = apr_palloc(r->pool, h.count);
210 h.pos = h.log;
211 h.end = h.log+h.count;
212
213 *h.pos++ = '+';
214 strcpy(h.pos, id);
215 h.pos += strlen(h.pos);
216 *h.pos++ = '|';
217 h.pos = log_escape(h.pos, h.end, r->the_request);
218
219 apr_table_do(log_headers, &h, r->headers_in, NULL);
220
221 ap_assert(h.pos < h.end);
222 *h.pos++ = '\n';
223
224 n = h.count-1;
225 rv = apr_file_write(cfg->fd, h.log, &n);
226 ap_assert(rv == APR_SUCCESS && n == h.count-1);
227
228 apr_table_setn(r->notes, "forensic-id", id);
229
230 return OK;
231}
232
233static int log_after(request_rec *r)
234{

Callers

nothing calls this directly

Calls 4

ap_get_module_configFunction · 0.85
ap_set_module_configFunction · 0.85
count_stringFunction · 0.85
log_escapeFunction · 0.85

Tested by

no test coverage detected