summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy/streaming_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp/reverseproxy/streaming_test.go')
-rw-r--r--modules/caddyhttp/reverseproxy/streaming_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/modules/caddyhttp/reverseproxy/streaming_test.go b/modules/caddyhttp/reverseproxy/streaming_test.go
new file mode 100644
index 0000000..4ed1f1e
--- /dev/null
+++ b/modules/caddyhttp/reverseproxy/streaming_test.go
@@ -0,0 +1,30 @@
+package reverseproxy
+
+import (
+ "bytes"
+ "strings"
+ "testing"
+)
+
+func TestHandlerCopyResponse(t *testing.T) {
+ h := Handler{}
+ testdata := []string{
+ "",
+ strings.Repeat("a", defaultBufferSize),
+ strings.Repeat("123456789 123456789 123456789 12", 3000),
+ }
+ dst := bytes.NewBuffer(nil)
+
+ for _, d := range testdata {
+ src := bytes.NewBuffer([]byte(d))
+ dst.Reset()
+ err := h.copyResponse(dst, src, 0)
+ if err != nil {
+ t.Errorf("failed with error: %v", err)
+ }
+ out := dst.String()
+ if out != d {
+ t.Errorf("bad read: got %q", out)
+ }
+ }
+}