aboutsummaryrefslogtreecommitdiff
path: root/header_regression_test.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-11-28 19:46:48 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-11-28 19:46:48 +0200
commit311af04a6738a897765dbc53e619adec6ea910f1 (patch)
treede0f818f9dec19ac2d1b14d4b638e156574729e9 /header_regression_test.go
parentIssue #6: allow setting content-type on on-POST requests (diff)
downloadfasthttp-311af04a6738a897765dbc53e619adec6ea910f1.tar.gz
fasthttp-311af04a6738a897765dbc53e619adec6ea910f1.tar.bz2
fasthttp-311af04a6738a897765dbc53e619adec6ea910f1.zip
Issue #6: Added missing test
Diffstat (limited to 'header_regression_test.go')
-rw-r--r--header_regression_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/header_regression_test.go b/header_regression_test.go
new file mode 100644
index 0000000..e7530d9
--- /dev/null
+++ b/header_regression_test.go
@@ -0,0 +1,30 @@
+package fasthttp
+
+import (
+ "bufio"
+ "bytes"
+ "testing"
+)
+
+func TestRequestHeaderSetContentType_Issue6(t *testing.T) {
+ contentType := "application/json"
+
+ var h RequestHeader
+ h.SetRequestURI("http://localhost/test")
+ h.SetContentType(contentType)
+
+ if string(h.ContentType()) != contentType {
+ t.Fatalf("unexpected content-type: %q. Expecting %q", h.ContentType(), contentType)
+ }
+ s := h.String()
+
+ var h1 RequestHeader
+
+ br := bufio.NewReader(bytes.NewBufferString(s))
+ if err := h1.Read(br); err != nil {
+ t.Fatalf("unexpected error: %s", err)
+ }
+ if string(h1.ContentType()) != contentType {
+ t.Fatalf("unexpected content-type: %q. Expecting %q", h1.ContentType(), contentType)
+ }
+}