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

如何在劫持中设置请求头? #929

Closed
OneSeven opened this issue Aug 28, 2023 · 3 comments
Closed

如何在劫持中设置请求头? #929

OneSeven opened this issue Aug 28, 2023 · 3 comments
Labels
question Questions related to rod

Comments

@OneSeven
Copy link

OneSeven commented Aug 28, 2023

Rod Version: v0.114.3

router:= subPage.HijackRequests()
router.MustAdd("*", func(ctx *rod.Hijack) {
	ctx.Request.Req().Header.Add("Referer", "url")
	ctx.ContinueRequest(&proto.FetchContinueRequest{})
})

上述代码无效

@OneSeven OneSeven added the question Questions related to rod label Aug 28, 2023
@ysmood
Copy link
Member

ysmood commented Aug 28, 2023

#322

@ysmood ysmood closed this as completed Aug 28, 2023
@OneSeven
Copy link
Author

@ysmood

@ysmood
Copy link
Member

ysmood commented Aug 28, 2023

r.Req().Header.Set("Test", "header") // override request header

rod/hijack_test.go

Lines 66 to 67 in 0af5471

// send request load response from real destination as the default value to hijack
ctx.MustLoadResponse()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions related to rod
Projects
None yet
Development

No branches or pull requests

2 participants