我正在嘗試使用 Go 創(chuàng)建一個(gè)代理服務(wù)器,該服務(wù)器將請(qǐng)求正文中的某些值更改為 API,但是當(dāng)發(fā)送請(qǐng)求時(shí),會(huì)發(fā)生以下恐慌并且請(qǐng)求失?。?015/05/03 14:17:52 http: panic serving 192.168.1.139:42818: runtime error: invalid memory address or nil pointer dereferencegoroutine 72 [running]:net/http.func·011() /usr/lib/go/src/pkg/net/http/server.go:1100 +0xb1runtime.panic(0x8258ee0, 0x83b3733) /usr/lib/go/src/pkg/runtime/panic.c:248 +0x176main.viewResponse(0x0, 0x1861b470, 0x1860ed01) /home/bradley/turbocharger/proxy.go:40 +0xa2github.com/elazarl/goproxy.FuncRespHandler.Handle(0x82e6480, 0x0, 0x1861b470, 0x1) /home/bradley/gopath/src/github.com/elazarl/goproxy/actions.go:35 +0x39github.com/elazarl/goproxy.func·016(0x0, 0x1861b470, 0x827a768) /home/bradley/gopath/src/github.com/elazarl/goproxy/dispatcher.go:279 +0x18fgithub.com/elazarl/goproxy.FuncRespHandler.Handle(0x1868c9b0, 0x0, 0x1861b470, 0x4) /home/bradley/gopath/src/github.com/elazarl/goproxy/actions.go:35 +0x39github.com/elazarl/goproxy.(*ProxyHttpServer).filterResponse(0x18682640, 0x0, 0x1861b470, 0x0) /home/bradley/gopath/src/github.com/elazarl/goproxy/proxy.go:69 +0x95github.com/elazarl/goproxy.(*ProxyHttpServer).ServeHTTP(0x18682640, 0xb74dd780, 0x18601260, 0x18600bd0) /home/bradley/gopath/src/github.com/elazarl/goproxy/proxy.go:115 +0x39bnet/http.serverHandler.ServeHTTP(0x18681dc0, 0xb74dd780, 0x18601260, 0x18600bd0) /usr/lib/go/src/pkg/net/http/server.go:1673 +0x155net/http.(*conn).serve(0x18628a00) /usr/lib/go/src/pkg/net/http/server.go:1174 +0x8c6created by net/http.(*Server).Serve /usr/lib/go/src/pkg/net/http/server.go:1721 +0x2be這是腳本:func viewResponse(response *http.Response, ctx *goproxy.ProxyCtx) *http.Response { log.Printf("Response: %s", response.Status) return response}
- 1 回答
- 0 關(guān)注
- 257 瀏覽
添加回答
舉報(bào)
0/150
提交
取消