Skip to content

Commit

Permalink
chore: fixes short write error.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcchavezs committed Nov 27, 2023
1 parent e6cbb66 commit cfa6aba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/nightly-caddy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:

jobs:
nightly-caddy:
name: "Nightly Caddy (caddy version: ${{ github.event.inputs.caddyversion || 'master' }})"
strategy:
matrix:
go-version: [1.20.x]
Expand Down
5 changes: 3 additions & 2 deletions interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package coraza

import (
"errors"
"fmt"
"io"
"log"
Expand Down Expand Up @@ -73,7 +74,7 @@ func (i *rwInterceptor) Write(b []byte) (int, error) {
// if there is an interruption it must be from at least phase 4 and hence
// WriteHeader or Write should have been called and hence the status code
// has been flushed to the delegated response writer.
return 0, nil
return 0, errors.New("response writer is interrupted")
}

if !i.wroteHeader {
Expand All @@ -89,7 +90,7 @@ func (i *rwInterceptor) Write(b []byte) (int, error) {
i.overrideWriteHeader(it.Status)
// We only flush the status code after an interruption.
i.flushWriteHeader()
return 0, nil
return 0, errors.New("response writer is interrupted")
}
return n, err
}
Expand Down

0 comments on commit cfa6aba

Please sign in to comment.