static ngx_int_t rawstream_respond_status(subscriber_t *sub, ngx_int_t status_code, const ngx_str_t *status_line){ full_subscriber_t *fsub = (full_subscriber_t *)sub; //nchan_request_ctx_t *ctx = ngx_http_get_module_ctx(fsub->sub.request, ngx_nchan_module); if(status_code == NGX_HTTP_NO_CONTENT || (status_code == NGX_HTTP_NOT_MODIFIED && !status_line)) { //ignore return NGX_OK; } if(fsub->data.shook_hands == 0 && status_code >= 400 && status_code <600) { return subscriber_respond_unqueued_status(fsub, status_code, status_line); } subscriber_maybe_dequeue_after_status_response(fsub, status_code); return NGX_OK; }
static ngx_int_t chunked_respond_status(subscriber_t *sub, ngx_int_t status_code, const ngx_str_t *status_line){ nchan_buf_and_chain_t bc; ngx_chain_t *chain = NULL; full_subscriber_t *fsub = (full_subscriber_t *)sub; if(chain == NULL) { bc.chain.buf=&bc.buf; bc.chain.next=NULL; ngx_memzero(&bc.buf, sizeof(ngx_buf_t)); bc.buf.last_buf = 1; bc.buf.last_in_chain = 1; bc.buf.flush = 1; bc.buf.memory = 1; chain = &bc.chain; } bc.buf.start = (u_char *)"0\r\n\r\n"; bc.buf.end = bc.buf.start + 5; bc.buf.pos = bc.buf.start; bc.buf.last = bc.buf.end; if(status_code == NGX_HTTP_NO_CONTENT || (status_code == NGX_HTTP_NOT_MODIFIED && !status_line)) { //ignore return NGX_OK; } if(fsub->data.shook_hands == 0 && status_code >= 400 && status_code < 600) { nchan_respond_status(sub->request, status_code, status_line, 1); return NGX_OK; } chunked_ensure_headers_sent(fsub); nchan_output_filter(fsub->sub.request, chain); subscriber_maybe_dequeue_after_status_response(fsub, status_code); return NGX_OK; }
static ngx_int_t multipart_respond_status(subscriber_t *sub, ngx_int_t status_code, const ngx_str_t *status_line){ nchan_buf_and_chain_t *bc; static u_char *end_boundary=(u_char *)"--\r\n"; full_subscriber_t *fsub = (full_subscriber_t *)sub; //nchan_request_ctx_t *ctx = ngx_http_get_module_ctx(fsub->sub.request, nchan_module); if(status_code == NGX_HTTP_NO_CONTENT || (status_code == NGX_HTTP_NOT_MODIFIED && !status_line)) { //ignore return NGX_OK; } if(fsub->data.shook_hands == 0 && status_code >= 400 && status_code <600) { nchan_respond_status(sub->request, status_code, status_line, 1); return NGX_OK; } multipart_ensure_headers_sent(fsub); if((bc = nchan_bufchain_pool_reserve(fsub_bcp(fsub), 1)) == NULL) { nchan_respond_status(sub->request, NGX_HTTP_INTERNAL_SERVER_ERROR, NULL, 1); return NGX_ERROR; } ngx_memzero(&bc->buf, sizeof(ngx_buf_t)); bc->buf.memory = 1; bc->buf.last_buf = 1; bc->buf.last_in_chain = 1; bc->buf.flush = 1; bc->buf.start = end_boundary; bc->buf.pos = end_boundary; bc->buf.end = end_boundary + 4; bc->buf.last = bc->buf.end; nchan_output_filter(fsub->sub.request, &bc->chain); subscriber_maybe_dequeue_after_status_response(fsub, status_code); return NGX_OK; }