Skip to content

httpProxy#1

Draft
sjorsdonkers wants to merge 1 commit intomainfrom
httpProxy
Draft

httpProxy#1
sjorsdonkers wants to merge 1 commit intomainfrom
httpProxy

Conversation

@sjorsdonkers
Copy link
Copy Markdown

Adding a http proxy with similar logging for http requests to /json/list /json/version etc.

return
}
defer ws.Close()
if websocket.IsWebSocketUpgrade(r) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would try to avoid using else.
And since I consider the function ws main usage is to proxify a web socket. I would rewrite this way:

if !websocket.IsWebSocketUpgrade(r) {
	// If not a WebSocket upgrade request, handle it as an HTTP request
	// We may expect requests like /json/list or /json/version
	if err := httpProxy(cdpurl, w, r); err != nil {
		slog.Error("httpProxy", slog.Any("err", err))
	}
	return
}

ws, err := upgrader.Upgrade(w, r, nil)
// ...

Copy link
Copy Markdown
Member

@krichprollsch krichprollsch left a comment

Choose a reason for hiding this comment

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

The goal of the PR is to connect to chrome w/o having to copy the unique ws url?


// Create a new request to the target
targetURL := httpurl + r.URL.Path
req, err := http.NewRequest(r.Method, targetURL, tee_body)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
req, err := http.NewRequest(r.Method, targetURL, tee_body)
req, err :=http.NewRequestWithContext(r.Context(), r.Method, targetURL, tee_body)

This way if the caller cancel the original request, you will abort the proxy one.

@sjorsdonkers
Copy link
Copy Markdown
Author

The goal of the PR is to connect to chrome w/o having to copy the unique ws url?

The goal is to see whether we can get Chrome DevTools working using remote-debugging.

With this change Lightpanda shows up in chrome, but the inspect button does not work yet, we do see in this proxy that chrome is sending unimplemented cdp commands.

@sjorsdonkers sjorsdonkers marked this pull request as draft May 22, 2025 12:14
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.

2 participants