Replies: 7 comments
-
|
Do you want to see the result in the output? If yes, you can try using package main
import (
"fmt"
"log"
"github.com/projectdiscovery/goflags"
"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/gologger/levels"
"github.com/projectdiscovery/httpx/runner"
)
func main() {
gologger.DefaultLogger.SetMaxLevel(levels.LevelVerbose)
options := runner.Options{
Methods: "GET",
InputTargetHost: goflags.StringSlice{"https://projectdiscovery.io"},
DisableStdin: true,
OutputMatchCondition: `status_code == 200 && regex("html", body)`,
OnResult: func(r runner.Result) {
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 {
log.Fatal(err)
}
httpxRunner, err := runner.New(&options)
if err != nil {
log.Fatal(err)
}
defer httpxRunner.Close()
httpxRunner.RunEnumeration()
} |
Beta Was this translation helpful? Give feedback.
-
|
I'm filtering a batch of URL requests to find those with a 200 status code and a specific string in the response body. The problem is that the regex("html", body) DSL expression always returns an empty body. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
I couldn't repro the second issue you mentioned with the code I've shared. |
Beta Was this translation helpful? Give feedback.
-
|
@c0r1 the problem is the current configuration of the runner sets max response body size to read to 0 (int zero value). Adding the below to your options does the trick. It's not ideal but it seems to be what the current client requires.
|
Beta Was this translation helpful? Give feedback.
-
Thanks! I've set it up with the configuration you suggested (MaxResponseBodySizeToRead: int(httpx.DefaultOptions.MaxResponseBodySizeToRead)), and it's working as expected now – I'm getting the desired results. |
Beta Was this translation helpful? Give feedback.
-
|
Moving this to discussion as we are not tracking SDK/Library usage-related implementations as issues. |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
httpx version:
v1.6.10
Current Behavior:
When using HTTPX as a library with the -mdc (Match Condition) option enabled, the ResponseBody attribute of the Result object remains empty, even though the actual HTTP response contains a body. I have confirmed that the server is indeed sending a non-empty response body.
Expected Behavior:
When the HTTP response contains a body, the ResponseBody attribute should not be empty and should reflect the actual content of the response.
Steps To Reproduce:
Running the above code does not yield any matching results, even though the response body should match the specified condition (
status_code == 200 && regex("html", body)).However, executing the equivalent HTTPX command-line command correctly produces the expected results.
httpx -u https://projectdiscovery.io -mdc 'status_code == 200 && regex("html", body)'This command correctly returns the expected results, indicating that the issue is specific to the library usage.
Beta Was this translation helpful? Give feedback.
All reactions