Skip to content

Commit 02e8fdd

Browse files
authored
Fix http: superfluous response.write header call (#11)
* Remove version * Write status before content
1 parent d4c19f1 commit 02e8fdd

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

captcha.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ import (
2828
"gopkg.in/macaron.v1"
2929
)
3030

31-
const _VERSION = "0.1.0"
32-
33-
func Version() string {
34-
return _VERSION
35-
}
36-
3731
var (
3832
defaultChars = []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
3933
)
@@ -242,10 +236,10 @@ func Captchaer(options ...Options) macaron.Handler {
242236
}
243237
}
244238

239+
ctx.Status(200)
245240
if _, err := NewImage([]byte(chars), cpt.StdWidth, cpt.StdHeight, cpt.ColorPalette).WriteTo(ctx.Resp); err != nil {
246241
panic(fmt.Errorf("write captcha: %v", err))
247242
}
248-
ctx.Status(200)
249243
return
250244
}
251245

captcha_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ import (
2424
"gopkg.in/macaron.v1"
2525
)
2626

27-
func Test_Version(t *testing.T) {
28-
Convey("Get version", t, func() {
29-
So(Version(), ShouldEqual, _VERSION)
30-
})
31-
}
32-
3327
func Test_Captcha(t *testing.T) {
3428
Convey("Captch service", t, func() {
3529
m := macaron.New()

0 commit comments

Comments
 (0)