Skip to content
Snippets Groups Projects
Commit 585b5189 authored by Antoine Prieels's avatar Antoine Prieels
Browse files

[IMP] hw_drivers: Remove http.py.iotpatch


We used to patch http.py using a diff. This was really not practical
because every time the file was modified, the diff had to be recreated.
We now override the specific methods directly.

closes odoo/odoo#60366

X-original-commit: a6012f03
Signed-off-by: default avatarQuentin Lejeune (qle) <qle@odoo.com>
Signed-off-by: default avatarAntoine Prieëls <aprieels@users.noreply.github.com>
parent f0781b79
Branches
Tags
No related merge requests found
......@@ -6,5 +6,6 @@ from . import controllers
from . import driver
from . import event_manager
from . import exception_logger
from . import http
from . import interface
from . import main
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import http
class IoTBoxHttpRequest(http.HttpRequest):
def dispatch(self):
if self._is_cors_preflight(http.request.endpoint):
# Using the PoS in debug mode in v12, the call to '/hw_proxy/handshake' contains the
# 'X-Debug-Mode' header, which was removed from 'Access-Control-Allow-Headers' in v13.
# When the code of http.py is not checked out to v12 (i.e. in Community), the connection
# fails as the header is rejected and none of the devices can be used.
headers = {
'Access-Control-Max-Age': 60 * 60 * 24,
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, Authorization, X-Debug-Mode'
}
return http.Response(status=200, headers=headers)
return super(IoTBoxHttpRequest, self).dispatch()
class IoTBoxRoot(http.Root):
def setup_db(self, httprequest):
# No database on the IoT Box
pass
def get_request(self, httprequest):
# Override HttpRequestwith IoTBoxHttpRequest
if httprequest.mimetype not in ("application/json", "application/json-rpc"):
return IoTBoxHttpRequest(httprequest)
return super(IoTBoxRoot, self).get_request(httprequest)
http.Root = IoTBoxRoot
http.root = IoTBoxRoot()
--- http_old.py 2020-10-07 15:25:08.432430021 +0200
+++ http_new.py 2020-10-07 15:26:05.088492713 +0200
@@ -764,7 +764,7 @@
if self._is_cors_preflight(request.endpoint):
headers = {
'Access-Control-Max-Age': 60 * 60 * 24,
- 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
+ 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, Authorization, X-Debug-Mode'
}
return Response(status=200, headers=headers)
@@ -1510,7 +1510,7 @@
"""
httprequest = httprequest or request.httprequest
- dbs = db_list(True, httprequest)
+ dbs = []
# try the db already in the session
db_session = httprequest.session.db
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment