Skip to content

Commit 0c078ee

Browse files
committed
修复提交url的bug以及默认会重定向bug,目前不会301跳转。
1 parent 9fbc290 commit 0c078ee

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

cmd/commons/core/runner.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func (r *Runner) Run() {
7777
return
7878
}
7979
log.Info("Total URLs: ", len(urls))
80+
8081
for i < len(urls) {
8182
//TODO 老代码
8283
//for t := 0; t < k; t++ {
@@ -102,19 +103,20 @@ func (r *Runner) Run() {
102103
//}
103104

104105
for t := 0; t < k; t++ {
105-
if i == len(urls)-1 {
106+
task := func() {
107+
log.Debugf(" %d %s %d", t, urls[i-1], i)
108+
Start2(urls[i-1], hashmap) // Start k goroutines
109+
wg.Done()
110+
}
111+
if i == len(urls) {
106112
break
107113
}
108114
if urls[i] != "" {
109115
// 通道通信 发送url 并且 i++
110116
//c := make(chan int)
111117
log.Debugf("Now Threads: %d", t)
112118
wg.Add(1)
113-
err := pool.Submit(func() {
114-
log.Debugf("Running Submit %d url is %s %d", t, urls[i], i)
115-
Start2(urls[i], hashmap, i) // Start k goroutines
116-
wg.Done()
117-
})
119+
err := pool.Submit(task)
118120
i++
119121
if err != nil {
120122
log.Error("Error submitting job " + urls[i])
@@ -128,6 +130,7 @@ func (r *Runner) Run() {
128130
}
129131

130132
}
133+
wg.Wait()
131134

132135
}
133136

@@ -160,7 +163,7 @@ func Start(u string, hashmap map[string]interface{}, i int, c chan int) {
160163

161164
}
162165

163-
func Start2(u string, hashmap map[string]interface{}, i int) {
166+
func Start2(u string, hashmap map[string]interface{}) {
164167
log.Infof("%s Runner started", u)
165168
//log.Infoln("testing URL: ", u)
166169
//for k, v := range hashmap {

cmd/commons/utils/httpclient.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ func InIt(mode int, timeout int, proxy string, retry int, h1 bool) (client *req.
2424
client.SetTimeout(time.Duration(timeout) * time.Second)
2525
client.SetCommonRetryCount(retry)
2626
client.EnableInsecureSkipVerify()
27+
// 重定向设置
28+
client.SetRedirectPolicy(req.NoRedirectPolicy())
2729
// 设置代理
2830
f := IsProxyUrl(proxy)
2931
if f {

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ github.com/tj/go-update v2.2.4+incompatible/go.mod h1:waFwwyiAhGey2e+dNoYQ/iLhIc
169169
github.com/tj/go-update v2.2.5-0.20200519121640-62b4b798fd68+incompatible h1:guTq1YxwB8XSILkI9q4IrOmrCOS6Hc1L3hmOhi4Swcs=
170170
github.com/tj/go-update v2.2.5-0.20200519121640-62b4b798fd68+incompatible/go.mod h1:waFwwyiAhGey2e+dNoYQ/iLhIcFqhCW7zL/+vDU1WLo=
171171
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
172+
github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I=
172173
github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
173174
github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8=
174175
github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=

0 commit comments

Comments
 (0)