Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/bypass_url_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,23 @@ def _run_curl(self, item):
# Notes: subprocess.Popen with text=True => universal_newlines=True so maybe useless
result = result.replace(os.linesep, "\n")

# Store command result in CurlItem object
if self.proxy and "HTTP/1.0 200 Connection established" in result:
# Delete the additional response proxy header 'HTTP/1.0 200 Connection established'
item.response_raw_output = result.split("\n", 2)[2]
else:
item.response_raw_output = result
# Ensure no false-positives when using proxy
if self.proxy:
# Look for any HTTP response after CONNECT, supporting both HTTP/1.x and HTTP/2
response_parts = re.split(
r"(?:HTTP/1\.1 200 Connection established.*?\r?\n\r?\n)(HTTP/(?:[12](?:\.[01])?)\s+\d{3})",
result,
flags=re.DOTALL
)
if len(response_parts) > 1:
item.response_raw_output = response_parts[1] + response_parts[2]
else:
# Fallback pattern - look for any HTTP response
match = re.search(r"(HTTP/(?:[12](?:\.[01])?)\s+\d{3}.*$)", result, re.DOTALL)
if match:
item.response_raw_output = match.group(1)
else:
item.response_raw_output = result

# Remove from retry list if present
if item in self.to_retry_items:
Expand Down
Loading