Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go1.5 httpclient bug!Wait online! in a hurry! ! #45263

Closed
yangQingYu123 opened this issue Mar 27, 2021 · 2 comments
Closed

go1.5 httpclient bug!Wait online! in a hurry! ! #45263

yangQingYu123 opened this issue Mar 27, 2021 · 2 comments

Comments

@yangQingYu123
Copy link

The problem of using go httpclient to request https, I am sure it is not the problem of the https server accessed by the certificate, because it is normal for me to send the same parameters using postman and curl. I think it is a bug in version go1.5.

$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\1\AppData\Local\go-build
set GOENV=C:\Users\1\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=F:\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=F:\go
set GOPRIVATE=
set GOPROXY=https://goproxy.io,direct
set GOROOT=D:\go
set GOSUMDB=off
set GOTMPDIR=
set GOTOOLDIR=D:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\1\AppData\Local\Temp\go-build947164270=/tmp/go-build -gno-record-gcc-switches

go code EOF
package main

import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)

func main() {

url := "https://api.cmburl.cn:8065/ect/cbl-v2.0-uat/order-pay"
method := "POST"

payload := strings.NewReader({"orderExtendPayDto":{"accInputType":"01","payerIssrId":"","transChannelType":"01","transIp":"::1","transTerminalType":"07"},"orderInfoPayDto":{"appId":"f2275583-0e92-42f7-89c5-47a3d4f640e7","asyncNtfUrl":"http://code.itc.cmbchina.cn/LSSD/lu84_polypay_alipay/commits/dev","frontNtfUrl":"http://99.11.3.152:8080/test-show","mchNbr":"755936044710301","mchOrderNbr":"595342639696449536","mchTransNbr":"5953426396964495361616743634","orderAmt":"0.01","orderCcyNbr":"10","orderPostTime":"20210326152714","orderRemark":"订单支付0.01元","orderSubtype":"DRT","orderType":"PAY","payerIssrId":"","pltNbr":"C000000137","pltRemark":"测试支付","urlTimeLimit":30}})

client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)

if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Appid", "f2275583-0e92-42f7-89c5-47a3d4f640e7")
req.Header.Add("Timestamp", "1616743634")
req.Header.Add("Sign", "b68c0085fa49e2f3b1361419699a917d92f552b78e38ddfbcdf4b5fbac7ee065")
req.Header.Add("Apisign", "jDEd9a5XUDmugMfuDRLjVSbKM6E1QCO4XS3yF6eWdOVulj+kkHQGgyDNDrKRRE4R3oUfc1H4kyBySNC9cvstYT0nFDUR34wpCGHh6PgRpezznOd91ogTsdF2o9fAir2blU+zbNokJuCKrq/CJ2xEwyXdunWuuiRyVw4iXEqXdWoSfJTkE7Dj9JbCNX3GdW499dQUbeIJ0sNeYHch6oSsBWLcrvL6EXprtfQAFYAPsPAnzdWXxmVkJjeye44kv5zEuTu993iIvseH8GU0giMjEV+FmHh1s7TO1ZEVdCa3R0o8gWkXUDXGa79qQLoB529+BKwoL5+NgeH5oCYSWHXbuQ==")
req.Header.Add("Version", "1.0")
req.Header.Add("Datetime", "2021-03-26 15:27:14")
req.Header.Add("Content-Type", "application/json")

res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()

body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}

curl code success
curl --location --request POST 'https://api.cmburl.cn:8065/ect/cbl-v2.0-uat/order-pay' \
--header 'Appid: f2275583-0e92-42f7-89c5-47a3d4f640e7' \
--header 'Timestamp: 1616743634' \
--header 'Sign: b68c0085fa49e2f3b1361419699a917d92f552b78e38ddfbcdf4b5fbac7ee065' \
--header 'Apisign: jDEd9a5XUDmugMfuDRLjVSbKM6E1QCO4XS3yF6eWdOVulj+kkHQGgyDNDrKRRE4R3oUfc1H4kyBySNC9cvstYT0nFDUR34wpCGHh6PgRpezznOd91ogTsdF2o9fAir2blU+zbNokJuCKrq/CJ2xEwyXdunWuuiRyVw4iXEqXdWoSfJTkE7Dj9JbCNX3GdW499dQUbeIJ0sNeYHch6oSsBWLcrvL6EXprtfQAFYAPsPAnzdWXxmVkJjeye44kv5zEuTu993iIvseH8GU0giMjEV+FmHh1s7TO1ZEVdCa3R0o8gWkXUDXGa79qQLoB529+BKwoL5+NgeH5oCYSWHXbuQ==' \
--header 'Version: 1.0' \
--header 'Datetime: 2021-03-26 15:27:14' \
--header 'Content-Type: application/json' \
--data-raw '{"orderExtendPayDto":{"accInputType":"01","payerIssrId":"","transChannelType":"01","transIp":"::1","transTerminalType":"07"},"orderInfoPayDto":{"appId":"f2275583-0e92-42f7-89c5-47a3d4f640e7","asyncNtfUrl":"http://code.itc.cmbchina.cn/LSSD/lu84_polypay_alipay/commits/dev","frontNtfUrl":"http://99.11.3.152:8080/test-show","mchNbr":"755936044710301","mchOrderNbr":"595342639696449536","mchTransNbr":"5953426396964495361616743634","orderAmt":"0.01","orderCcyNbr":"10","orderPostTime":"20210326152714","orderRemark":"订单支付0.01元","orderSubtype":"DRT","orderType":"PAY","payerIssrId":"","pltNbr":"C000000137","pltRemark":"测试支付","urlTimeLimit":30}}'

@yangQingYu123
Copy link
Author

Wait online! in a hurry! !

@yangQingYu123 yangQingYu123 changed the title go httpclient bug go httpclient bug!Wait online! in a hurry! ! Mar 27, 2021
@yangQingYu123 yangQingYu123 changed the title go httpclient bug!Wait online! in a hurry! ! go1.5 httpclient bug!Wait online! in a hurry! ! Mar 27, 2021
@seankhliao
Copy link
Member

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@golang golang locked and limited conversation to collaborators Mar 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants