来自python
import requests
requests.get('https://git.eclipse.org/r/changes/?q=since:{2018-01-01 00:00:00.000}+AND+until:{2018-01-01 22:59:59.999}')
工作就像魅力。
在Go中,
client := &http.Client{Timeout: time.Second * 10}
response, err := client.Get("https://git.eclipse.org/r/changes/?q=since:{2018-01-01 00:00:00.000}+AND+until:{2018-01-01 22:59:59.999}")
导致不良请求(400(。
我认为,问题是URL中卷曲括号的编码。我该如何修复?
您需要逃脱查询字符串:
client.Get("https://git.eclipse.org/r/changes/?q=" + url.QueryEscape("since:{2018-01-01 00:00:00.000}+AND+until:{2018-01-01 22:59:59.999}"))
您可能需要将+
恢复到空间,因为它们被逃脱了。