Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
noO0ob committed Jan 15, 2025
1 parent 29e2d8d commit 174949a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lyrebird/mock/handlers/handler_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from lyrebird import utils
from lyrebird import application
from lyrebird.log import get_logger
from lyrebird.utils import CaseInsensitiveDict
from lyrebird.mock.blueprints.apis.bandwidth import config
from urllib.parse import urlparse, unquote
from .http_data_helper import DataHelper
Expand Down Expand Up @@ -66,7 +67,10 @@ def _parse_request(self):
raw_headers = None
# Read raw headers
if '_raw_header' in self.request.environ:
raw_headers = HeadersHelper.get_raw_headers(self.request)
raw_headers = CaseInsensitiveDict(self.request.environ['_raw_header'])
for key in ('cache-control', 'host', 'transfer-encoding', 'lyrebird-client-address'):
if key in raw_headers:
del raw_headers[key]
# Proxy-Raw-Headers will be removed in future
elif 'Proxy-Raw-Headers' in self.request.headers:
raw_headers = json.loads(self.request.headers['Proxy-Raw-Headers'])
Expand Down
11 changes: 8 additions & 3 deletions lyrebird/mock/handlers/http_data_helper/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections import OrderedDict
from . import content_encoding, content_type
from ..http_header_helper import HeadersHelper
from lyrebird.utils import CaseInsensitiveDict
import json

Expand Down Expand Up @@ -28,7 +27,10 @@ def origin2flow(origin_obj, output=None, chain=None):

# Read raw headers, support the request from extra mock 9999 port
if '_raw_header' in origin_obj.environ:
raw_headers = HeadersHelper.get_raw_headers(origin_obj)
raw_headers = CaseInsensitiveDict(origin_obj.environ['_raw_header'])
for key in ('cache-control', 'host', 'transfer-encoding', 'lyrebird-client-address'):
if key in raw_headers:
del raw_headers[key]
elif 'Proxy-Raw-Headers' in origin_obj.headers:
_origin_headers = json.loads(origin_obj.headers['Proxy-Raw-Headers'])
raw_headers = CaseInsensitiveDict(_origin_headers)
Expand Down Expand Up @@ -74,7 +76,10 @@ def origin2string(origin_obj, output=None):

# Read raw headers, support the request from extra mock 9999 port
if '_raw_header' in origin_obj.environ:
raw_headers = HeadersHelper.get_raw_headers(origin_obj)
raw_headers = CaseInsensitiveDict(origin_obj.environ['_raw_header'])
for key in ('cache-control', 'host', 'transfer-encoding', 'lyrebird-client-address'):
if key in raw_headers:
del raw_headers[key]
elif 'Proxy-Raw-Headers' in origin_obj.headers:
_origin_headers = json.loads(origin_obj.headers['Proxy-Raw-Headers'])
raw_headers = CaseInsensitiveDict(_origin_headers)
Expand Down

0 comments on commit 174949a

Please sign in to comment.