diff --git a/lyrebird/mock/handlers/http_data_helper/__init__.py b/lyrebird/mock/handlers/http_data_helper/__init__.py index 240bcb906..52834df0b 100644 --- a/lyrebird/mock/handlers/http_data_helper/__init__.py +++ b/lyrebird/mock/handlers/http_data_helper/__init__.py @@ -1,5 +1,7 @@ from collections import OrderedDict from . import content_encoding, content_type +from lyrebird.utils import CaseInsensitiveDict +import json origin2flow_handlers = OrderedDict({ 'Content-Encoding': content_encoding, @@ -23,8 +25,15 @@ def origin2flow(origin_obj, output=None): if not _data: return + # Read raw headers, support the request from extra mock 9999 port + if 'Proxy-Raw-Headers' in origin_obj.headers: + _origin_headers = json.loads(origin_obj.headers['Proxy-Raw-Headers']) + raw_headers = CaseInsensitiveDict(_origin_headers) + else: + raw_headers = origin_obj.headers + for headers_key, func in origin2flow_handlers.items(): - headers_val = origin_obj.headers.get(headers_key, '') + headers_val = raw_headers.get(headers_key, '') _data = func.origin2flow(headers_val, _data) if output: diff --git a/lyrebird/utils.py b/lyrebird/utils.py index 7891994d9..4dbef7344 100644 --- a/lyrebird/utils.py +++ b/lyrebird/utils.py @@ -50,3 +50,14 @@ def find_free_port(): s.bind(('', 0)) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) return s.getsockname()[1] + + +class CaseInsensitiveDict(dict): + def __setitem__(self, key, value): + super(CaseInsensitiveDict, self).__setitem__(key.lower(), value) + + def __getitem__(self, key): + return super(CaseInsensitiveDict, self).__getitem__(key.lower()) + + def get(self, key, default=None): + return super(CaseInsensitiveDict, self).get(key.lower(), default) diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index a0825e559..000000000 --- a/sonar-project.properties +++ /dev/null @@ -1,11 +0,0 @@ -sonar.projectKey=Meituan-Dianping_lyrebird -# this is the name and version displayed in the SonarCloud UI. -sonar.projectName=lyrebird -sonar.projectVersion=1.0 - -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -# This property is optional if sonar.modules is set. -sonar.sources=. - -# Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 diff --git a/vetur.config.js b/vetur.config.js new file mode 100644 index 000000000..ffe04926a --- /dev/null +++ b/vetur.config.js @@ -0,0 +1,3 @@ +module.exports = { + projects: ["./frontend"], +};