From 61d86bebc727f87c699ada7ff901ee3de78e335c Mon Sep 17 00:00:00 2001 From: huangsimin Date: Fri, 17 Apr 2020 13:15:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dgcurl=E4=B8=8A=E7=9A=84bug,?= =?UTF-8?q?=20=E5=B9=B6=E4=B8=94=E8=B0=83=E6=95=B4requests=E4=B8=BA?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 4 ++++ hunter_test.go | 2 +- pre_curl_com.go | 2 +- pre_curl_com_test.go | 12 ++++++++++-- pre_url_com_test.go | 2 +- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 469799b..172b3f0 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.14 require ( github.com/474420502/focus v0.8.1 - github.com/474420502/gurl v0.0.2 + github.com/474420502/gcurl v0.0.4 github.com/474420502/requests v1.5.0 github.com/Pallinder/go-randomdata v1.1.0 github.com/lestrrat-go/libxml2 v0.0.0-20200215080510-6483566f52cb diff --git a/go.sum b/go.sum index 630bde3..79e5e2e 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,10 @@ cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSR cloud.google.com/go v0.41.0/go.mod h1:OauMR7DV8fzvZIl2qg6rkaIhD/vmgk4iwEw/h6ercmg= github.com/474420502/focus v0.8.1 h1:PZwCgzcnxwx7ZZCWc/XKLVaZPH9e4YX9cP4ckyT2HDA= github.com/474420502/focus v0.8.1/go.mod h1:jrDXvK1CnUJ3PCR3ZJVYinbS2Yz5kM8OoAbCLe6AF7Y= +github.com/474420502/gcurl v0.0.3 h1:gbvJ9JiiiaCkLispDZ9tlJPFo8K4e7t4JTFze3UlHHc= +github.com/474420502/gcurl v0.0.3/go.mod h1:qtCzAZZbVRIsBt0lNUh2I0qDniU9T3E21aSsVUYo7Hc= +github.com/474420502/gcurl v0.0.4 h1:eR1BNXvQ4T245dotWpjDzAMWch+FTTfScqzsdq93JK0= +github.com/474420502/gcurl v0.0.4/go.mod h1:qtCzAZZbVRIsBt0lNUh2I0qDniU9T3E21aSsVUYo7Hc= github.com/474420502/gurl v0.0.2 h1:j1XJSd41M8v1M9glkIVFTR00j87DEt4JoeITELP8Pfk= github.com/474420502/gurl v0.0.2/go.mod h1:gM500QucE2upVvM4eRIVAhP6gLbcCVEemJdzS1Qbf5E= github.com/474420502/requests v1.4.0 h1:dnufhTVTo/N1SdWVqBKm4xKDRb0N4P7D7Zg1FJFO29I= diff --git a/hunter_test.go b/hunter_test.go index e4536a9..0cd641b 100644 --- a/hunter_test.go +++ b/hunter_test.go @@ -33,7 +33,7 @@ func (web *WebPost) Execute(cxt *TaskContext) { if err != nil { panic(err) } - cxt.SetShare("test", resp.Content()) + cxt.SetShare("test", string(resp.Content())) } func TestCasePostForm(t *testing.T) { diff --git a/pre_curl_com.go b/pre_curl_com.go index 652eb00..0dc1b0f 100644 --- a/pre_curl_com.go +++ b/pre_curl_com.go @@ -1,7 +1,7 @@ package hunter import ( - gcurl "github.com/474420502/gurl" + gcurl "github.com/474420502/gcurl" ) // PreCurlUrl Task的 curl bash 预处理组件 diff --git a/pre_curl_com_test.go b/pre_curl_com_test.go index 44f2899..cfb7654 100644 --- a/pre_curl_com_test.go +++ b/pre_curl_com_test.go @@ -14,11 +14,19 @@ func (web *WebGurl) Execute(cxt *TaskContext) { if err != nil { panic(err) } - cxt.SetShare("test", resp.Content()) + cxt.SetShare("test", string(resp.Content())) } func TestCurlCom(t *testing.T) { - curlBash := "curl 'http://httpbin.org/' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.9' --compressed --insecure" + curlBash := `curl + 'http://httpbin.org/' + -H 'Connection: keep-alive' + -H 'Cache-Control: max-age=0' + -H 'Upgrade-Insecure-Requests: 1' + -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36' + -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' + -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.9' + --compressed --insecure` hunter := NewHunter(&WebGurl{PreCurlUrl(curlBash)}) // first params PreCurlUrl hunter.Execute() diff --git a/pre_url_com_test.go b/pre_url_com_test.go index be4da51..fc74597 100644 --- a/pre_url_com_test.go +++ b/pre_url_com_test.go @@ -14,7 +14,7 @@ func (web *WebPreUrl) Execute(cxt *TaskContext) { if err != nil { panic(err) } - cxt.SetShare("test", resp.Content()) + cxt.SetShare("test", string(resp.Content())) } func TestCasePreUrl(t *testing.T) {