We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
func (analyzer *myAnalyzer) Analyze( resp *module.Response) (dataList []module.Data, errorList []error) { analyzer.ModuleInternal.IncrHandlingNumber() defer analyzer.ModuleInternal.DecrHandlingNumber() analyzer.ModuleInternal.IncrCalledCount() if resp == nil { errorList = append(errorList, genParameterError("nil response")) return } httpResp := resp.HTTPResp() if httpResp == nil { errorList = append(errorList, genParameterError("nil HTTP response")) return } httpReq := httpResp.Request if httpReq == nil { errorList = append(errorList, genParameterError("nil HTTP request")) return } var reqURL = httpReq.URL if reqURL == nil { errorList = append(errorList, genParameterError("nil HTTP request URL")) return } analyzer.ModuleInternal.IncrAcceptedCount() respDepth := resp.Depth() logger.Infof("Parse the response (URL: %s, depth: %d)... \n", reqURL, respDepth) // 解析HTTP响应。 if httpResp.Body != nil { defer httpResp.Body.Close() } multipleReader, err := reader.NewMultipleReader(httpResp.Body) if err != nil { errorList = append(errorList, genError(err.Error())) return } dataList = []module.Data{} for _, respParser := range analyzer.respParsers { httpResp.Body = multipleReader.Reader() pDataList, pErrorList := respParser(httpResp, respDepth) if pDataList != nil { for _, pData := range pDataList { if pData == nil { continue } dataList = appendDataList(dataList, pData, respDepth) } } if pErrorList != nil { for _, pError := range pErrorList { if pError == nil { continue } errorList = append(errorList, pError) } } } if len(errorList) == 0 { analyzer.ModuleInternal.IncrCompletedCount() } return dataList, errorList }
// 解析HTTP响应。 if httpResp.Body != nil { defer httpResp.Body.Close() } multipleReader, err := reader.NewMultipleReader(httpResp.Body) if err != nil { errorList = append(errorList, genError(err.Error())) return } dataList = []module.Data{} for _, respParser := range analyzer.respParsers { httpResp.Body = multipleReader.Reader() pDataList, pErrorList := respParser(httpResp, respDepth) ..... }
httpResp.Body = multipleReader.Reader()
The text was updated successfully, but these errors were encountered:
嗯,是有这个隐患,我改进一下吧。
Sorry, something went wrong.
No branches or pull requests
httpResp.Body = multipleReader.Reader()
这里httpResp.Body赋了一个新值,是否会导致原来的Body没有关闭从而造成内存泄漏The text was updated successfully, but these errors were encountered: