Skip to content

Conversation

@0x123456789
Copy link
Contributor

Hello ProjectDiscovery team, seam like we cant parse HTTP2 request from bytes or string because of version logic. I have the following usecase:

  1. I get this response from Burp:
HTTP/2 200 OK
Server: nginx/1.17.9
Date: Sat, 30 Mar 2024 17:36:11 GMT
Content-Type: application/javascript; charset=utf-8
Access-Control-Allow-Origin: *
Cache-Control: public, max-age=31556952
Etag: W/"af07e301570ab6511cd61c64c4fb822c"
Expires: Sun, 30 Mar 2025 23:20:38 GMT
Last-Modified: Fri, 15 Mar 2024 13:33:33 GMT

And just want to parse it this way:

type nullWriterReader struct {
	io.Reader
}

func (nw nullWriterReader) Write(p []byte) (n int, err error) {
	return len(p), nil
}

...
// data - is gziped Response
if reader, err = gzip.NewReader(bytes.NewReader(data)); err != nil {
		c.JSON(errors.BadRequestError(err))
		return
}

rw := nullWriterReader{reader}
client := client.NewClient(rw)
res, err := client.ReadResponse(false)

ReadResponse return error because it doesn't know about HTTP/2 can be without minor version then calling ReadVersion(). My commit should help solve this case

@ehsandeep ehsandeep requested a review from Mzack9999 March 30, 2024 18:59
@0x123456789
Copy link
Contributor Author

I know it's not like "real" HTTP/2 support, but this simple changes allow to read response for example from text file

Copy link
Member

@Mzack9999 Mzack9999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! - The definitive solution would be forking the standard library and removing all validations as done in #112 (unfinished)

@0x123456789
Copy link
Contributor Author

@Mzack9999 Thank you, can this pull request be merged?

@ehsandeep ehsandeep merged commit a3d8154 into projectdiscovery:main Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants