mirror of
https://github.com/projectdiscovery/httpx.git
synced 2024-08-16 13:00:24 +03:00
Update callback calling place
- Callback for every result, even it contains error - User can handle it using Result.Err
This commit is contained in:
parent
addddf1e1b
commit
bc7ac8d073
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/projectdiscovery/goflags"
|
||||
@ -14,8 +15,16 @@ func main() {
|
||||
|
||||
options := runner.Options{
|
||||
Methods: "GET",
|
||||
InputTargetHost: goflags.StringSlice{"scanme.sh", "projectdiscovery.io"},
|
||||
InputTargetHost: goflags.StringSlice{"scanme.sh", "projectdiscovery.io", "localhost"},
|
||||
//InputFile: "./targetDomains.txt", // path to file containing the target domains list
|
||||
OnResult: func(r runner.Result) {
|
||||
// handle error
|
||||
if r.Err != nil {
|
||||
fmt.Printf("[Err] %s: %s\n", r.Input, r.Err)
|
||||
return
|
||||
}
|
||||
fmt.Printf("%s %s %d\n", r.Input, r.Host, r.StatusCode)
|
||||
},
|
||||
}
|
||||
|
||||
if err := options.ValidateOptions(); err != nil {
|
||||
|
@ -262,11 +262,12 @@ type Options struct {
|
||||
ListDSLVariable bool
|
||||
OutputFilterCondition string
|
||||
OutputMatchCondition string
|
||||
OnResult OnResultCallback
|
||||
DisableUpdateCheck bool
|
||||
NoDecode bool
|
||||
Screenshot bool
|
||||
UseInstalledChrome bool
|
||||
//The OnResult callback function is invoked for each result. It is important to check for errors in the result before using Result.Err.
|
||||
OnResult OnResultCallback
|
||||
DisableUpdateCheck bool
|
||||
NoDecode bool
|
||||
Screenshot bool
|
||||
UseInstalledChrome bool
|
||||
}
|
||||
|
||||
// ParseOptions parses the command line options for application
|
||||
|
@ -663,6 +663,13 @@ func (r *Runner) RunEnumeration() {
|
||||
}
|
||||
|
||||
for resp := range output {
|
||||
|
||||
// call the callback function if any
|
||||
// be careful and check for result.Err
|
||||
if r.options.OnResult != nil {
|
||||
r.options.OnResult(resp)
|
||||
}
|
||||
|
||||
if resp.Err != nil {
|
||||
// Change the error message if any port value passed explicitly
|
||||
if url, err := r.parseURL(resp.URL); err == nil && url.Port() != "" {
|
||||
|
Loading…
Reference in New Issue
Block a user