MCPcopy
hub / github.com/shadow1ng/fscan / SafeHTTPDo

Function SafeHTTPDo

common/network.go:165–183  ·  view source on GitHub ↗

SafeHTTPDo 带发包控制的HTTP请求

(client *http.Client, req *http.Request)

Source from the content-addressed store, hash-verified

163
164// SafeHTTPDo 带发包控制的HTTP请求
165func SafeHTTPDo(client *http.Client, req *http.Request) (*http.Response, error) {
166 // 检查发包限制
167 if canSend, reason := CanSendPacket(); !canSend {
168 LogError(fmt.Sprintf("HTTP请求 %s 受限: %s", req.URL.String(), reason))
169 return nil, fmt.Errorf("发包受限: %s", reason)
170 }
171
172 // 执行HTTP请求
173 resp, err := client.Do(req)
174
175 // 统计TCP包数量 (HTTP本质上是TCP)
176 if err != nil {
177 GetGlobalState().IncrementTCPFailedPacketCount()
178 } else {
179 GetGlobalState().IncrementTCPSuccessPacketCount()
180 }
181
182 return resp, err
183}

Callers 1

tryHTTPMethod · 0.92

Calls 6

CanSendPacketFunction · 0.85
LogErrorFunction · 0.85
GetGlobalStateFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected