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

Sec-CH-UA is not overridden for 30X redirects #13

Open
Mattwmaster58 opened this issue Dec 13, 2024 · 0 comments
Open

Sec-CH-UA is not overridden for 30X redirects #13

Mattwmaster58 opened this issue Dec 13, 2024 · 0 comments

Comments

@Mattwmaster58
Copy link
Owner

Mattwmaster58 commented Dec 13, 2024

On the redirected request, Sec-CH-UA is not properly overridden. I suspect this is a Chrome issue, and CDP spec isn't really specific on how Network.setExtraHTTPHeaders should work for headers that are already sent.

import asyncio
from playwright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page(extra_http_headers={"sec-ch-ua": "ARBITRARY"})
        await page.goto('http://127.0.0.1:9919')

asyncio.run(main())

Server:

from flask import Flask, request, redirect, make_response

app = Flask(__name__)
secch = "sec-ch-ua"


@app.route('/')
def handle_request():
    print(f"{secch}: {request.headers.get(secch)}")
    response = make_response(redirect('/cookie-set'))
    return response, 301


@app.route('/cookie-set')
def handle_requesta():
    cookie_name = '301-redirect-cookie'
    print(f"{secch}: {request.headers.get(secch)}")
    return 'cookie set!', 200


if __name__ == '__main__':
    app.run(debug=True, port=9919)

Output from server:

sec-ch-ua: ARBITRARY
sec-ch-ua: "HeadlessChrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"
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

No branches or pull requests

1 participant