Comment 8 for bug 1509262

Revision history for this message
Olivier Tilloy (osomon) wrote : Re: Browser stop working while watching a video on Youtube

This appears to be a bug in oxide, where the user agent overrides are not used for redirections (e.g. HTTP 302).
I can reproduce locally with the following standalone code:

== server.py ==

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import http.server as http
import threading

class HTTPRequestHandler(http.BaseHTTPRequestHandler):
    def do_GET(self):
        if self.path == "/foo":
            self.send_response(302)
            self.send_header("Location", "http://localhost:8080/bar")
            self.end_headers()
            self.wfile.write(b"foo")
        elif self.path == "/bar":
            self.send_response(200)
            self.send_header("Content-Type", "text/plain")
            self.end_headers()
            self.wfile.write(b"bar")
        else:
            self.send_error(404)

if __name__ == '__main__':
    server = http.HTTPServer(("", 8080), HTTPRequestHandler)
    server.allow_reuse_address = True
    server.serve_forever()

== client.qml ==

import QtQuick 2.4
import com.canonical.Oxide 1.9

WebView {
    url: "http://localhost:8080/foo"
    context: WebContext {
        userAgent: "default"
        userAgentOverrides: [
            ["^http:\/\/localhost:8080\/foo", "overridden1"],
            ["^http:\/\/localhost:8080\/bar", "overridden2"],
        ]
    }
}

Then run `python3 server.py` in one terminal, monitor network traffic with e.g. wireshark, and in another terminal run `qmlscene client.qml`.

The request to "/foo" has the first override as expected, but it redirects to "/bar" and the corresponding request still has the first override, instead of the second one.