Go: http.Flusher implemented by unit.response.
This closes #133 issue on GitHub.
This commit is contained in:
@@ -31,6 +31,23 @@ nxt_go_response_write(nxt_go_request_t r, uintptr_t buf, size_t len)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nxt_go_response_flush(nxt_go_request_t r)
|
||||
{
|
||||
nxt_go_run_ctx_t *ctx;
|
||||
|
||||
if (nxt_slow_path(r == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx = (nxt_go_run_ctx_t *) r;
|
||||
|
||||
if (ctx->nwbuf > 0) {
|
||||
nxt_go_ctx_flush(ctx, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
nxt_go_request_read(nxt_go_request_t r, uintptr_t dst, size_t dst_len)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,8 @@ typedef uintptr_t nxt_go_request_t;
|
||||
|
||||
int nxt_go_response_write(nxt_go_request_t r, uintptr_t buf, size_t len);
|
||||
|
||||
void nxt_go_response_flush(nxt_go_request_t r);
|
||||
|
||||
int nxt_go_request_read(nxt_go_request_t r, uintptr_t dst, size_t dst_len);
|
||||
|
||||
int nxt_go_request_close(nxt_go_request_t r);
|
||||
|
||||
@@ -65,3 +65,11 @@ func (r *response) WriteHeader(code int) {
|
||||
|
||||
r.Write([]byte("\r\n"))
|
||||
}
|
||||
|
||||
func (r *response) Flush() {
|
||||
if !r.headerSent {
|
||||
r.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
C.nxt_go_response_flush(r.c_req)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user