Explorar el Código

update code comments

pull/51/head
Jonathan Cobb hace 4 años
padre
commit
c8ee1fa846
Se han modificado 1 ficheros con 7 adiciones y 4 borrados
  1. +7
    -4
      bubble-server/src/main/resources/packer/roles/mitmproxy/files/bubble_flex.py

+ 7
- 4
bubble-server/src/main/resources/packer/roles/mitmproxy/files/bubble_flex.py Ver fichero

@@ -43,7 +43,7 @@ def set_flex_response(client_addr, flex_host, flow):
headers = flow.request.headers
headers[HEADER_FLEX_AUTH] = router['auth']
proxy_url = router['proxyUrl']
proxies = { "http": proxy_url, "https": proxy_url }
proxies = {"http": proxy_url, "https": proxy_url}

# send request to flex router
if bubble_log.isEnabledFor(DEBUG):
@@ -58,7 +58,9 @@ def set_flex_response(client_addr, flex_host, flow):
# Parse the response, we have to do this raw to capture the full status line

# Status line
next_bytes = response.raw.read(16384) # enough to read all headers
# 16K should be enough to capture status line and all headers
# see https://stackoverflow.com/questions/686217/maximum-on-http-header-values
next_bytes = response.raw.read(16384)
response_text = next_bytes.decode()
lines = response_text.splitlines()
status_line = lines[0]
@@ -83,12 +85,13 @@ def set_flex_response(client_addr, flex_host, flow):
bytes_consumed = bytes_consumed + len(header_line) + 1
if end_of_headers:
break
next_bytes = response.raw.read(8192)
next_bytes = response.raw.read(8192) # wow, headers are big! continue reading in 8K chunks
next_text = lines[-1] + '\n' + next_bytes.decode()
lines = next_text.splitlines()

flow.response.headers = response_headers

# Body -- prepend remainder left over from parsing headers
# Body
# Determine the remainder left over from parsing headers, send that first
remainder = next_bytes[bytes_consumed:]
flow.response.stream = prepend_remainder_to_stream(remainder, response.raw)

Cargando…
Cancelar
Guardar