mike820324 / microProxy

A http/https interceptor written in pure python.
MIT License
17 stars 3 forks source link

[Http1]: ProtocolError when redirect #159

Closed chhsiao90 closed 8 years ago

chhsiao90 commented 8 years ago

Use to reproduce

curl htttp://apple.com -I -L --socks5-hostname localhostL5580
Traceback (most recent call last):
  File "/Users/han-pc/workspace/python/microProxy/microproxy/proxy.py", line 42, in handle_stream
    yield self.layer_manager.run_layers(initial_layer, initial_context)
  File "/Users/han-pc/.pyenv/versions/mp/lib/python2.7/site-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/Users/han-pc/.pyenv/versions/mp/lib/python2.7/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "/Users/han-pc/.pyenv/versions/mp/lib/python2.7/site-packages/tornado/gen.py", line 1014, in run
    yielded = self.gen.throw(*exc_info)
  File "/Users/han-pc/workspace/python/microProxy/microproxy/layer_manager.py", line 37, in run_layers
    _handle_layer_error(error, current_context)
  File "/Users/han-pc/workspace/python/microProxy/microproxy/layer_manager.py", line 33, in run_layers
    current_context = yield current_layer.process_and_return_context()
  File "/Users/han-pc/.pyenv/versions/mp/lib/python2.7/site-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/Users/han-pc/.pyenv/versions/mp/lib/python2.7/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "/Users/han-pc/.pyenv/versions/mp/lib/python2.7/site-packages/tornado/gen.py", line 1014, in run
    yielded = self.gen.throw(*exc_info)
  File "/Users/han-pc/workspace/python/microProxy/microproxy/layer/application/http1.py", line 38, in process_and_return_context
    yield self.run_response()
  File "/Users/han-pc/.pyenv/versions/mp/lib/python2.7/site-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/Users/han-pc/.pyenv/versions/mp/lib/python2.7/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "/Users/han-pc/.pyenv/versions/mp/lib/python2.7/site-packages/tornado/gen.py", line 1017, in run
    yielded = self.gen.send(value)
  File "/Users/han-pc/workspace/python/microProxy/microproxy/layer/application/http1.py", line 72, in run_response
    self.dest_conn.receive(data, raise_exception=True)
  File "/Users/han-pc/workspace/python/microProxy/microproxy/protocol/http1.py", line 86, in receive
    body=b"".join(self._body_chunks)))
  File "/Users/han-pc/workspace/python/microProxy/microproxy/layer/application/http1.py", line 95, in on_response
    self.finish()
  File "/Users/han-pc/workspace/python/microProxy/microproxy/layer/application/http1.py", line 120, in finish
    self.src_conn.start_next_cycle()
  File "/Users/han-pc/.pyenv/versions/2.7.11/envs/mp/src/h11/h11/_connection.py", line 204, in start_next_cycle
    self._cstate.start_next_cycle()
  File "/Users/han-pc/.pyenv/versions/2.7.11/envs/mp/src/h11/h11/_state.py", line 298, in start_next_cycle
    raise LocalProtocolError("not in a reusable state")