Skip to content

Commit

Permalink
refactor: force-close when streaming all
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Oct 11, 2022
1 parent c70543c commit f0ccced
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion core/corehttp/gateway_handler_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ func (i *gatewayHandler) serveRawBlock(ctx context.Context, w http.ResponseWrite

// ServeContent will take care of
// If-None-Match+Etag, Content-Length and range requests
_, dataSent, _ := ServeContent(w, r, name, modtime, content)
_, dataSent, err := ServeContent(w, r, name, modtime, content)

if err != nil {
closeConnWithError(w, err)
}

if dataSent {
// Update metrics
Expand Down
2 changes: 1 addition & 1 deletion core/corehttp/gateway_handler_unixfs_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit
logger.Debugw("request processed", "tplDataDNSLink", dnslink, "tplDataSize", size, "tplDataBackLink", backLink, "tplDataHash", hash)

if err := listingTemplate.Execute(w, tplData); err != nil {
internalWebError(w, err)
closeConnWithError(w, err)
return
}

Expand Down
6 changes: 5 additions & 1 deletion core/corehttp/gateway_handler_unixfs_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ func (i *gatewayHandler) serveFile(ctx context.Context, w http.ResponseWriter, r

// ServeContent will take care of
// If-None-Match+Etag, Content-Length and range requests
_, dataSent, _ := ServeContent(w, r, name, modtime, content)
_, dataSent, err := ServeContent(w, r, name, modtime, content)

if err != nil {
closeConnWithError(w, err)
}

// Was response successful?
if dataSent {
Expand Down

0 comments on commit f0ccced

Please sign in to comment.