Project

General

Profile

fastcgi-404-always.diff

patch: always sends 404 if file is not present - bert, 2013-09-16 14:02

View differences:

src/mod_fastcgi.c (working copy)
2268 2268
						if (p->conf.debug) {
2269 2269
							log_error_write(srv, __FILE__, __LINE__, "ss", "Couldn't find range after filename:", filename);
2270 2270
						}
2271
						return 1;
2271
						return 502;
2272 2272
					}
2273 2273
					buffer_copy_string_len(srv->tmp_buf, filename, range - filename);
2274 2274

  
......
2282 2282
								"send-file error: couldn't get stat_cache entry for X-Sendfile2:",
2283 2283
								srv->tmp_buf);
2284 2284
						}
2285
						return 1;
2285
						return 404;
2286 2286
					} else if (!S_ISREG(sce->st.st_mode)) {
2287 2287
						if (p->conf.debug) {
2288 2288
							log_error_write(srv, __FILE__, __LINE__, "sb",
2289 2289
								"send-file error: wrong filetype for X-Sendfile2:",
2290 2290
								srv->tmp_buf);
2291 2291
						}
2292
						return 1;
2292
						return 502;
2293 2293
					}
2294 2294
					/* found the file */
2295 2295

  
......
2314 2314
						if (p->conf.debug) {
2315 2315
							log_error_write(srv, __FILE__, __LINE__, "ss", "Couldn't decode range after filename:", filename);
2316 2316
						}
2317
						return 1;
2317
						return 502;
2318 2318

  
2319 2319
range_success: ;
2320 2320
					}
......
2322 2322
					/* no parameters accepted */
2323 2323

  
2324 2324
					while (*pos == ' ') pos++;
2325
					if (*pos != '\0' && *pos != ',') return 1;
2325
					if (*pos != '\0' && *pos != ',') return 502;
2326 2326

  
2327 2327
					range_len = end_range - begin_range + 1;
2328
					if (range_len < 0) return 1;
2328
					if (range_len < 0) return 502;
2329 2329
					if (range_len != 0) {
2330 2330
						http_chunk_append_file(srv, con, srv->tmp_buf, begin_range, range_len);
2331 2331
					}
......
2484 2484

  
2485 2485
static int fcgi_demux_response(server *srv, handler_ctx *hctx) {
2486 2486
	int fin = 0;
2487
	int toread;
2487
	int toread, ret;
2488 2488
	ssize_t r;
2489 2489

  
2490 2490
	plugin_data *p    = hctx->plugin_data;
......
2596 2596
				}
2597 2597

  
2598 2598
				/* parse the response header */
2599
				if (fcgi_response_parse(srv, con, p, hctx->response_header)) {
2600
					con->http_status = 502;
2599
				if ((ret = fcgi_response_parse(srv, con, p, hctx->response_header))) {
2600
					con->http_status = ret;
2601 2601
					hctx->send_content_body = 0;
2602 2602
					con->file_started = 1;
2603 2603
					break;
......
2635 2635
						con->parsed_response |= HTTP_CONTENT_LENGTH;
2636 2636
						con->response.content_length = sce->st.st_size;
2637 2637
					} else {
2638
						log_error_write(srv, __FILE__, __LINE__, "sb",
2639
							"send-file error: couldn't get stat_cache entry for:",
2640
							ds->value);
2641
						con->http_status = 502;
2638
						con->http_status = 404;
2642 2639
						hctx->send_content_body = 0;
2643 2640
						con->file_started = 1;
2644 2641
						break;