Commit 6dcf308
committed
feat(nbhttp): Implement http.Flusher for streaming support
The existing `nbhttp.Response` did not implement the `http.Flusher`
interface, preventing its use with `http.NewResponseController` for
streaming data to the client. This was particularly problematic for
long-running requests or server-sent events (SSE). This change
introduces full support for `http.Flusher` and ensures true streaming is
possible by automatically enabling chunked encoding when a
`Content-Length` is not explicitly set. Key changes: - Added a `Flush()`
method to `Response` to implement `http.Flusher`. - Modified
`checkChunked()` to default to `Transfer-Encoding: chunked` for
responses without a `Content-Length`, which is crucial for streaming. -
Added a no-op `Push()` method to satisfy the `http.Pusher` interface,
returning an error as HTTP/2 Push is not supported.1 parent c26ae5e commit 6dcf308
1 file changed
+68
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
348 | 396 | | |
349 | 397 | | |
350 | 398 | | |
351 | 399 | | |
352 | 400 | | |
353 | 401 | | |
354 | 402 | | |
355 | | - | |
356 | 403 | | |
357 | 404 | | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
363 | 411 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
370 | 419 | | |
371 | 420 | | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
372 | 427 | | |
| 428 | + | |
373 | 429 | | |
374 | 430 | | |
375 | 431 | | |
| |||
0 commit comments