Skip to content

Commit

Permalink
Don't try to determine Content-Type based on the request URI extensio…
Browse files Browse the repository at this point in the history
…n, always use default Content-Type in the location.
  • Loading branch information
PiotrSikora committed Jul 1, 2010
1 parent a5b0e7c commit bf7f5d0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/ngx_postgres_output.c
Expand Up @@ -559,10 +559,11 @@ ngx_postgres_render_rds_row_terminator(ngx_http_request_t *r, ngx_pool_t *pool)
ngx_int_t
ngx_postgres_output_chain(ngx_http_request_t *r, ngx_chain_t *cl)
{
ngx_http_upstream_t *u = r->upstream;
ngx_postgres_loc_conf_t *pglcf;
ngx_postgres_ctx_t *pgctx;
ngx_int_t rc;
ngx_http_upstream_t *u = r->upstream;
ngx_http_core_loc_conf_t *clcf;
ngx_postgres_loc_conf_t *pglcf;
ngx_postgres_ctx_t *pgctx;
ngx_int_t rc;

dd("entering");

Expand All @@ -575,17 +576,20 @@ ngx_postgres_output_chain(ngx_http_request_t *r, ngx_chain_t *cl)
r->headers_out.status = pgctx->status ? pgctx->status : NGX_HTTP_OK;

if (pglcf->output_handler == &ngx_postgres_output_rds) {
/* RDS for output rds */
r->headers_out.content_type.data = (u_char *) rds_content_type;
r->headers_out.content_type.len = rds_content_type_len;
r->headers_out.content_type_len = rds_content_type_len;
r->headers_out.content_type_lowcase = NULL;
} else if (pglcf->output_handler != NULL) {
if (ngx_http_set_content_type(r) != NGX_OK) {
dd("returning NGX_HTTP_INTERNAL_SERVER_ERROR");
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
/* default type for output value|row */
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);

r->headers_out.content_type = clcf->default_type;
r->headers_out.content_type_len = clcf->default_type.len;
}

r->headers_out.content_type_lowcase = NULL;

rc = ngx_http_send_header(r);
if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
dd("returning rc:%d", (int) rc);
Expand Down
24 changes: 24 additions & 0 deletions test/t/output.t
Expand Up @@ -340,3 +340,27 @@ Content-Type: text/plain
GET /postgres
--- error_code: 500
--- timeout: 10
=== TEST 14: value - sanity (request with known extension)
--- http_config
upstream database {
postgres_server 127.0.0.1 dbname=test user=monty password=some_pass;
}
--- config
default_type text/plain;
location /postgres {
postgres_pass database;
postgres_query "select 'test', 'test' as echo";
postgres_output value 0 0;
}
--- request
GET /postgres.jpg
--- error_code: 200
--- response_headers
Content-Type: text/plain
--- response_body eval
"test"
--- timeout: 10

0 comments on commit bf7f5d0

Please sign in to comment.