Skip to content

httpx as library In v1.6.9 OnResult does not get error messages correctly. #2013

Closed

Description

@zhihuba

httpx version:

v1.6.9

Current Behavior:

options := runner.Options{
		Methods:         "GET",
		MaxRedirects:    2, 
		Timeout:         5, 
		InputTargetHost: goflags.StringSlice{"pipasdaxw.sh", "projectdiscovery.io", "localhost"},
		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)
		},
	}
Cannot get the error message correctly

Expected Behavior:

 httpx -u exasdama1sple.com -debug

    __    __  __       _  __
   / /_  / /_/ /_____ | |/ /
  / __ \/ __/ __/ __ \|   /
 / / / / /_/ /_/ /_/ /   |
/_/ /_/\__/\__/ .___/_/|_|
             /_/

                projectdiscovery.io

[INF] Current httpx version v1.6.8 (outdated)
[WRN] UI Dashboard is disabled, Use -dashboard option to enable
[INF] Dumped HTTP request for https://exasdama1sple.com

GET / HTTP/1.1
Host: exasdama1sple.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17 Safari/605.1.15
Accept-Charset: utf-8
Accept-Encoding: gzip

[INF] Dumped HTTP request for http://exasdama1sple.com

GET / HTTP/1.1
Host: exasdama1sple.com
User-Agent: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Accept-Charset: utf-8
Accept-Encoding: gzip

[DBG] Failed 'http://exasdama1sple.com': Get "http://exasdama1sple.com": errKind=network-permanent-error no address found for host

Get the error message. As in debug mode

Maybe the solution

vim httpx/runner/runner.go


if resp.str == "" {
	//Remove the following comment
	//if r.options.OnResult != nil {
		//r.options.OnResult(resp)
	//}
	continue
}

Activity

  1. added
    Type: BugInconsistencies or issues which will cause an issue or problem for users or implementors.
    on Nov 26, 2024
  2. Mzack9999 commented on Dec 8, 2024

    @Mzack9999
    Member

    The Probe flag should be set to true:

    options := runner.Options{
                    ...
    		Probe:           true,
    		...
    	}
  3. locked and limited conversation to collaborators on Dec 8, 2024
  4. converted this issue into a discussion #2026 on Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugInconsistencies or issues which will cause an issue or problem for users or implementors.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions