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

Missing header in hijack request #185

Open
thanhps42 opened this issue Aug 12, 2020 · 5 comments
Open

Missing header in hijack request #185

thanhps42 opened this issue Aug 12, 2020 · 5 comments
Labels
enhance New feature or request

Comments

@thanhps42
Copy link

When I hijack, the request missing these headers: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-Fetch-Dest

@thanhps42 thanhps42 added the bug When you are sure about it's a bug label Aug 12, 2020
@ysmood
Copy link
Member

ysmood commented Aug 13, 2020

Currently, we can use this event to get it:

page.EachEvent(func(e *proto.NetworkRequestWillBeSentExtraInfo) {
    fmt.Println(e)
})()

@ysmood ysmood added this to To do in Rod Aug 20, 2020
@ysmood ysmood moved this from To do to In progress in Rod Aug 20, 2020
@ysmood ysmood added enhance New feature or request and removed bug When you are sure about it's a bug labels Aug 27, 2020
@ysmood
Copy link
Member

ysmood commented Aug 27, 2020

After trying test code like this:

rod=cdp go test -v -run Test/TestHijackContinue$

func (s *S) TestHijackContinue() {
	url, engine, close := serve()
	defer close()

	// to simulate a backend server
	engine.GET("/", ginHTML(`<html>
	<body></body>
	<script>
		fetch('/a', { headers: { 'My-Header': 'test' } }).then(async (res) => {
			document.body.innerText = await res.text()
		})
	</script></html>`))
	engine.GET("/a", ginString(`ok`))

	router := s.page.HijackRequests()
	defer router.MustStop()

	router.MustAdd(url+"/a", func(ctx *rod.Hijack) {
		kit.Pause()
	})

	go router.Run()

	s.page.MustSetExtraHeaders("test", "b")
	s.page.MustNavigate(url)

	kit.Pause()
}

I found it's impossible to get the RequestWillBeSentExtraInfo for a paused request. Unless chrome adds new APIs to support it, we can't do much about it.

@ysmood ysmood moved this from In progress to To do in Rod Aug 27, 2020
@ysmood
Copy link
Member

ysmood commented Aug 27, 2020

@ysmood ysmood removed this from To do in Rod Oct 23, 2020
@ysmood

This comment has been minimized.

@Fly-Playgroud
Copy link
Contributor

#853

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhance New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants