Skip to content

Redirect function doesn't task effect when using httpx as library #2181

Closed

Description

@Caratpine

Hi team
here is my code:

package main

import (
	"fmt"
	"log"

	"github.com/projectdiscovery/httpx/runner"
)

func main() {
	targets := []string{
		"x.x.x.x",
	}
	options := &runner.Options{
		Methods:                 "GET",
		InputTargetHost:         targets,
		TLSGrab:                 true,
		Threads:                 50,
		Timeout:                 15,
		ResponseInStdout:        true,
		ResponseHeadersInStdout: true,
		RespectHSTS:             true,
		DisableUpdateCheck:      true,
		FollowHostRedirects:     true,
		FollowRedirects:         true,
		OnResult: func(r runner.Result) {
			if r.Err != nil {
				fmt.Printf("[Err] %s: %s\n", r.Input, r.Err)
				return
			}
			fmt.Println("header: ", r.ResponseHeaders)
			fmt.Println("request: ", r.Request)
			fmt.Println("response: ", r.Response.Raw)
			fmt.Println("url: ", r.URL)
		},
		Silent: true,
	}
	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()
}

I enabled FollowHostRedirects, FollowRedirects, RespectHSTS, but my http status code is already 3xx and does not redirect to 200. How can I solve this problem? Thank you

Activity

  1. added
    Type: Bug
    on May 16, 2025
  2. ehsandeep commented on May 16, 2025

    @ehsandeep
    Member

    Moving SDK related question to discussion

  3. locked and limited conversation to collaborators on May 16, 2025
  4. converted this issue into a discussion #2182 on May 16, 2025
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: Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions