卷曲工作正常:
curl --data "key=asdf" http://localhost:8080/
但在Go中我收到以下错误:
Post http://localhost:8080: dial tcp 127.0.0.1:8080: connection refused
这是代码:
func submitForm(value String){
resp,err := http.PostForm("http://localhost:8080",url.Values{"key": {value}})
if err != nil {
log.Fatal(err)
}
defer resp.body.Close()
_,err = IoUtil.ReadAll(resp.body)
if err != nil {
log.Fatal(err)
}
fmt.Println("status = ",resp.Status)
}
submitForm("asdf")
我用httpry监控了http流量,我发现没有生成http请求但是有一些包:
4 packets received,0 packets dropped,0 http packets parsed
更多事实:
>我的操作系统是Linux
>我使用PHP的内置Web服务器.使用此命令启动服务器:
PHP -S localhost:8080