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, ngx_chain_t *status_body){ 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) { return subscriber_respond_unqueued_status(fsub, status_code, status_line, status_body); } chunked_ensure_headers_sent(fsub); nchan_output_filter(fsub->sub.request, chain); subscriber_maybe_dequeue_after_status_response(fsub, status_code); return NGX_OK; }