Skip to content
New issue

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

Make http request dump with debug flag #425

Merged
merged 2 commits into from
Oct 30, 2021

Conversation

zerodivisi0n
Copy link
Contributor

Added http request and response dump for debug flag. Also added new flags debug-req and debug-resp to dump only requests or responses respectively.
This PR fixes #419.

Example output:

$ echo https://google.com | ./httpx --debug
    __    __  __       _  __
   / /_  / /_/ /_____ | |/ /
  / __ \/ __/ __/ __ \|   /
 / / / / /_/ /_/ /_/ /   |
/_/ /_/\__/\__/ .___/_/|_|
             /_/              v1.1.4-dev

                projectdiscovery.io

Use with caution. You are responsible for your actions.
Developers assume no liability and are not responsible for any misuse or damage.
[INF] Dumped HTTP request for https://google.com:443

GET / HTTP/1.1
Host: google.com
User-Agent: Mozilla/5.0 (Linux; Android 9; SM-G965F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.89 Mobile Safari/537.36
Accept-Charset: utf-8
Accept-Encoding: gzip

[INF] Dumped HTTP response for https://google.com:443

HTTP/1.1 301 Moved Permanently
Connection: close
Content-Length: 220
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000
Cache-Control: public, max-age=2592000
Content-Type: text/html; charset=UTF-8
Date: Sat, 23 Oct 2021 11:30:30 GMT
Expires: Mon, 22 Nov 2021 11:30:30 GMT
Location: https://www.google.com/
Server: gws
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>
https://google.com

@ehsandeep ehsandeep linked an issue Oct 23, 2021 that may be closed by this pull request
@ehsandeep ehsandeep requested a review from Ice3man543 October 23, 2021 16:39
@ehsandeep ehsandeep added the Status: Review Needed The issue has a PR attached to it which needs to be reviewed label Oct 23, 2021
@ehsandeep ehsandeep added Status: Completed Nothing further to be done with this issue. Awaiting to be closed. and removed Status: Review Needed The issue has a PR attached to it which needs to be reviewed labels Oct 30, 2021
@ehsandeep ehsandeep removed the request for review from Ice3man543 October 30, 2021 19:14
@ehsandeep ehsandeep merged commit 32ec662 into projectdiscovery:dev Oct 30, 2021
@z0neGit
Copy link

z0neGit commented Nov 22, 2021

@zerodivisi0n @ehsandeep
Hello, there will probably be painc error

...
	if r.options.Debug || r.options.DebugResponse {
		gologger.Info().Msgf("Dumped HTTP response for %s\n\n", fullURL)
		gologger.Print().Msgf("%s", string(resp.Raw)) // here
	}
...

when err is returned here

...
	resp, err := hp.Do(req, httpx.UnsafeOptions{URIPath: reqURI}) // here
	if r.options.ShowStatistics {
		r.stats.IncrementCounter("requests", 1)
	}
...

@zerodivisi0n
Copy link
Contributor Author

Thanks for your report, @z0neGit. I suggested a fix here: #439

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Status: Completed Nothing further to be done with this issue. Awaiting to be closed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debug flag enhancement
3 participants