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

Function log_script

modules/generators/mod_cgid.c:1191–1294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1189};
1190
1191static int log_script(request_rec *r, cgid_server_conf * conf, int ret,
1192 char *dbuf, const char *sbuf, apr_bucket_brigade *bb,
1193 apr_file_t *script_err)
1194{
1195 const apr_array_header_t *hdrs_arr = apr_table_elts(r->headers_in);
1196 const apr_table_entry_t *hdrs = (apr_table_entry_t *) hdrs_arr->elts;
1197 char argsbuffer[HUGE_STRING_LEN];
1198 apr_file_t *f = NULL;
1199 apr_bucket *e;
1200 const char *buf;
1201 apr_size_t len;
1202 apr_status_t rv;
1203 int first;
1204 int i;
1205 struct stat finfo;
1206 char time_str[APR_CTIME_LEN];
1207
1208 /* XXX Very expensive mainline case! Open, then getfileinfo! */
1209 if (!conf->logname ||
1210 ((stat(conf->logname, &finfo) == 0)
1211 && (finfo.st_size > conf->logbytes)) ||
1212 (apr_file_open(&f, conf->logname,
1213 APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT, r->pool) != APR_SUCCESS)) {
1214 /* Soak up script output */
1215 discard_script_output(bb);
1216 if (script_err) {
1217 while (apr_file_gets(argsbuffer, HUGE_STRING_LEN,
1218 script_err) == APR_SUCCESS)
1219 continue;
1220 }
1221 return ret;
1222 }
1223
1224 /* "%% [Wed Jun 19 10:53:21 1996] GET /cgid-bin/printenv HTTP/1.0" */
1225 apr_ctime(time_str, apr_time_now());
1226 apr_file_printf(f, "%%%% [%s] %s %s%s%s %s\n", time_str, r->method, r->uri,
1227 r->args ? "?" : "", r->args ? r->args : "", r->protocol);
1228 /* "%% 500 /usr/local/apache/cgid-bin" */
1229 apr_file_printf(f, "%%%% %d %s\n", ret, r->filename);
1230
1231 apr_file_puts("%request\n", f);
1232 for (i = 0; i < hdrs_arr->nelts; ++i) {
1233 if (!hdrs[i].key)
1234 continue;
1235 apr_file_printf(f, "%s: %s\n", hdrs[i].key, hdrs[i].val);
1236 }
1237 if ((r->method_number == M_POST || r->method_number == M_PUT)
1238 && *dbuf) {
1239 apr_file_printf(f, "\n%s\n", dbuf);
1240 }
1241
1242 apr_file_puts("%response\n", f);
1243 hdrs_arr = apr_table_elts(r->err_headers_out);
1244 hdrs = (const apr_table_entry_t *) hdrs_arr->elts;
1245
1246 for (i = 0; i < hdrs_arr->nelts; ++i) {
1247 if (!hdrs[i].key)
1248 continue;

Callers

nothing calls this directly

Calls 2

discard_script_outputFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected