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

Function scan_meta_file

modules/metadata/mod_cern_meta.c:208–265  ·  view source on GitHub ↗

XXX: this is very similar to ap_scan_script_header_err_core... * are the differences deliberate, or just a result of bit rot? */

Source from the content-addressed store, hash-verified

206 * are the differences deliberate, or just a result of bit rot?
207 */
208static int scan_meta_file(request_rec *r, apr_file_t *f)
209{
210 char w[MAX_STRING_LEN];
211 char *l;
212 int p;
213 apr_table_t *tmp_headers;
214
215 tmp_headers = apr_table_make(r->pool, 5);
216 while (apr_file_gets(w, MAX_STRING_LEN - 1, f) == APR_SUCCESS) {
217
218 /* Delete terminal (CR?)LF */
219 p = strlen(w);
220 if (p > 0 && w[p - 1] == '\n') {
221 if (p > 1 && w[p - 2] == '\015')
222 w[p - 2] = '\0';
223 else
224 w[p - 1] = '\0';
225 }
226
227 if (w[0] == '\0') {
228 return OK;
229 }
230
231 /* if we see a bogus header don't ignore it. Shout and scream */
232
233 if (!(l = strchr(w, ':'))) {
234 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01560)
235 "malformed header in meta file: %s", r->filename);
236 return HTTP_INTERNAL_SERVER_ERROR;
237 }
238
239 *l++ = '\0';
240 while (apr_isspace(*l))
241 ++l;
242
243 if (!ap_cstr_casecmp(w, "Content-type")) {
244 char *tmp;
245 /* Nuke trailing whitespace */
246
247 char *endp = l + strlen(l) - 1;
248 while (endp > l && apr_isspace(*endp))
249 *endp-- = '\0';
250
251 tmp = apr_pstrdup(r->pool, l);
252 ap_content_type_tolower(tmp);
253 ap_set_content_type(r, tmp);
254 }
255 else if (!ap_cstr_casecmp(w, "Status")) {
256 sscanf(l, "%d", &r->status);
257 r->status_line = apr_pstrdup(r->pool, l);
258 }
259 else {
260 apr_table_set(tmp_headers, w, l);
261 }
262 }
263 apr_table_overlap(r->headers_out, tmp_headers, APR_OVERLAP_TABLES_SET);
264 return OK;
265}

Callers 1

add_cern_meta_dataFunction · 0.85

Calls 3

ap_cstr_casecmpFunction · 0.85
ap_content_type_tolowerFunction · 0.85
ap_set_content_typeFunction · 0.85

Tested by

no test coverage detected