Skip to content

Commit 9320c3c

Browse files
committed
code cleaning
1 parent 7ae35d1 commit 9320c3c

File tree

1 file changed

+5
-89
lines changed

1 file changed

+5
-89
lines changed

src/ngx_link_func_module.c

Lines changed: 5 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,7 @@ static void ngx_http_link_func_client_body_handler(ngx_http_request_t *r);
133133
static ngx_int_t ngx_http_link_func_proceed_init_calls(ngx_cycle_t* cycle, ngx_http_link_func_srv_conf_t *scf, ngx_http_link_func_main_conf_t* mcf);
134134
static u_char* ngx_http_link_func_strdup_with_p(ngx_pool_t *pool, const char *src, size_t len);
135135

136-
// static ngx_int_t ngx_http_link_func_get_resp_var(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data);
137-
// static void ngx_http_link_func_set_resp_var_with_r(ngx_http_request_t *r, ngx_link_func_ctx_t *ctx, const char* resp_content, size_t resp_len);
138-
// #if (NGX_THREADS) && (nginx_version > 1013003)
139-
// static void ngx_http_link_func_output_filter(ngx_http_request_t *r);
140-
// #else
141136
static ngx_int_t ngx_http_link_func_output_filter(ngx_http_request_t *r);
142-
// #endif
143137

144138
#if (NGX_THREADS) && (nginx_version > 1013003)
145139
static void ngx_http_link_func_after_process(ngx_event_t *ev);
@@ -423,7 +417,6 @@ ngx_http_link_func_validation_check_and_set_str_slot(ngx_conf_t *cf, ngx_command
423417
return NGX_CONF_OK;
424418
}
425419

426-
427420
// static char *ngx_http_link_func_srv_post_conf_handler(ngx_conf_t *cf, void *data, void *conf) {
428421
// ngx_str_t *value = conf;
429422
// ngx_http_link_func_srv_conf_t *scf = ngx_http_conf_get_module_srv_conf(cf, ngx_http_link_func_module);
@@ -1009,12 +1002,7 @@ ngx_http_link_func_precontent_handler(ngx_http_request_t *r) {
10091002
if (internal_ctx->aio_processing) {
10101003
return NGX_AGAIN;
10111004
} else {
1012-
// #if (NGX_THREADS) && (nginx_version > 1013003)
1013-
// ngx_http_link_func_output_filter(r);
1014-
// return NGX_OK;
1015-
// #else
10161005
return NGX_DECLINED;
1017-
// #endif
10181006
}
10191007

10201008
new_task:
@@ -1024,8 +1012,8 @@ ngx_http_link_func_precontent_handler(ngx_http_request_t *r) {
10241012
new_ctx->__log__ = r->connection->log;
10251013
new_ctx->shared_mem = (void*)mcf->shm_ctx->shared_mem;
10261014

1027-
/***Set to default incase link library does not return anything ***/
1028-
internal_ctx->rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
1015+
/***Set to NGX_HTTP_NOT_FOUND incase function handler or it has subrequest does not return anything ***/
1016+
internal_ctx->rc = NGX_HTTP_NOT_FOUND;
10291017

10301018
if (r->args.len > 0) {
10311019
new_ctx->req_args = ngx_pcalloc(r->pool, r->args.len + 1);
@@ -1613,14 +1601,6 @@ ngx_link_func_write_resp_l(
16131601

16141602
ngx_http_request_t *r = (ngx_http_request_t*)appctx->__r__;
16151603

1616-
// if ( ((ngx_http_link_func_loc_conf_t*) ngx_http_get_module_loc_conf(r, ngx_http_link_func_module) )->_is_call_to_var ) {
1617-
// ngx_log_error(NGX_LOG_WARN,
1618-
// r->connection->log,
1619-
// 0, "Recommended to call ngx_http_link_func_set_resp_var. ngx_http_link_func_write_resp only applicable when no variable specified");
1620-
// ngx_http_link_func_set_resp_var_with_r(r, appctx, resp_content, resp_content_len);
1621-
// return;
1622-
// }
1623-
16241604
internal_ctx = ngx_http_get_module_ctx(r, ngx_http_link_func_module);
16251605

16261606
if (internal_ctx == NULL) {
@@ -1682,69 +1662,6 @@ ngx_link_func_write_resp(
16821662
);
16831663
}
16841664

1685-
// #if (NGX_THREADS) && (nginx_version > 1013003)
1686-
// static void
1687-
// ngx_http_link_func_output_filter(
1688-
// ngx_http_request_t *r
1689-
// ) {
1690-
// ngx_int_t rc;
1691-
// ngx_chain_t out;
1692-
// ngx_http_link_func_internal_ctx_t *internal_ctx;
1693-
// ngx_str_t *resp_content_type, *resp_status_line;
1694-
// ngx_buf_t *b;
1695-
1696-
// internal_ctx = ngx_http_get_module_ctx(r, ngx_http_link_func_module);
1697-
1698-
// if (internal_ctx == NULL) {
1699-
// ngx_log_error(NGX_LOG_EMERG, r->connection->log, 0, "Session is not valid");
1700-
// ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
1701-
// return;
1702-
// }
1703-
1704-
// if (internal_ctx->rc == NGX_HTTP_INTERNAL_SERVER_ERROR) {
1705-
// ngx_log_error(NGX_LOG_EMERG, r->connection->log, 0, "Apps Internal Server error");
1706-
// ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
1707-
// return;
1708-
// }
1709-
1710-
// resp_status_line = &internal_ctx->status_line;
1711-
// resp_content_type = &internal_ctx->content_type;
1712-
// b = internal_ctx->resp_content;
1713-
1714-
// r->headers_out.status = internal_ctx->status_code;
1715-
1716-
// if (resp_status_line->len) {
1717-
// r->headers_out.status_line.len = resp_status_line->len;
1718-
// r->headers_out.status_line.data = resp_status_line->data;
1719-
// }
1720-
1721-
// /* Set the Content-Type header. */
1722-
// r->headers_out.content_type.len = resp_content_type->len;
1723-
// r->headers_out.content_type.data = resp_content_type->data;
1724-
1725-
// /* Get the content length of the body. */
1726-
// r->headers_out.content_length_n = ngx_buf_size(b);
1727-
1728-
// rc = ngx_http_send_header(r); /* Send the headers */
1729-
// if (rc == NGX_ERROR) {
1730-
// ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "response processing failed.");
1731-
// // ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
1732-
// rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
1733-
// ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
1734-
// return;
1735-
1736-
// }
1737-
1738-
// /* Insertion in the buffer chain. */
1739-
// out.buf = b;
1740-
// out.next = NULL; /* just one buffer */
1741-
1742-
// /* Send the body, and return the status code of the output filter chain. */
1743-
// // ngx_http_finalize_request(r, ngx_http_output_filter(r, &out)); // only using when request client body
1744-
// // rc = ngx_http_output_filter(r, &out);
1745-
// ngx_http_output_filter(r, &out);
1746-
// }
1747-
// #else
17481665
static ngx_int_t
17491666
ngx_http_link_func_output_filter(
17501667
ngx_http_request_t *r
@@ -1762,9 +1679,9 @@ ngx_http_link_func_output_filter(
17621679
return NGX_HTTP_INTERNAL_SERVER_ERROR;
17631680
}
17641681

1765-
if (internal_ctx->rc == NGX_HTTP_INTERNAL_SERVER_ERROR) {
1766-
ngx_log_error(NGX_LOG_EMERG, r->connection->log, 0, "Apps Internal Server error");
1767-
return NGX_HTTP_INTERNAL_SERVER_ERROR;
1682+
if (internal_ctx->rc == NGX_HTTP_NOT_FOUND) {
1683+
/** might not handle content phase, request routed to the next handler **/
1684+
return NGX_HTTP_NOT_FOUND;
17681685
}
17691686

17701687
resp_status_line = &internal_ctx->status_line;
@@ -1800,7 +1717,6 @@ ngx_http_link_func_output_filter(
18001717
// ngx_http_finalize_request(r, ngx_http_output_filter(r, &out)); // only using when request client body
18011718
return ngx_http_output_filter(r, &out);
18021719
}
1803-
// #endif
18041720

18051721
/****Download Feature Support ****/
18061722
static int

0 commit comments

Comments
 (0)