genotrance / px

An HTTP proxy server to automatically authenticate through an NTLM proxy
MIT License
962 stars 100 forks source link

composer patches provoke error in mcurl.py: curl.xheaders is None but no check before loop #214

Open aitjes opened 8 months ago

aitjes commented 8 months ago

I use composer for my PHP Project and use it to apply patches during composer install. The Patches fail with Failed to open stream: Cannot connect to HTTPS server through proxy. It works with CNTLM. px proxy logs the following error:

Process-2: Thread_1: 1711525471: /do_curl/do/dprint: 9870398c5f7235dd536e3a8ba8f140323bbce2ca: Getting active socket
Process-2: Thread_1: 1711525471: /do_curl/select/dprint: 9870398c5f7235dd536e3a8ba8f140323bbce2ca: Starting select loop
Process-2: Thread_1: 1711525471: /do_curl/select/dprint: 9870398c5f7235dd536e3a8ba8f140323bbce2ca: Sending original client headers
----------------------------------------
Exception occurred during processing of request from ('x.x.x.x', 34248)
Traceback (most recent call last):
  File "/usr/lib/python3.10/socketserver.py", line 683, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.10/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.10/socketserver.py", line 747, in __init__
    self.handle()
  File "/usr/lib/python3.10/http/server.py", line 433, in handle
    self.handle_one_request()
  File "/home/dev/.local/lib/python3.10/site-packages/px/handler.py", line 128, in handle_one_request
    http.server.BaseHTTPRequestHandler.handle_one_request(self)
  File "/usr/lib/python3.10/http/server.py", line 421, in handle_one_request
    method()
  File "/home/dev/.local/lib/python3.10/site-packages/px/handler.py", line 248, in do_CONNECT
    self.do_curl()
  File "/home/dev/.local/lib/python3.10/site-packages/px/handler.py", line 206, in do_curl
    STATE.mcurl.select(self.curl, self.connection, STATE.idle)
  File "/home/dev/.local/lib/python3.10/site-packages/px/mcurl.py", line 1025, in select
    for header in curl.xheaders:
TypeError: 'NoneType' object is not iterable
----------------------------------------

px-proxy Version is 0.9.2

Example composer.json if someone want to reproduce: composer.json

Checking with if curl.xheaders is not None before the loop fixes the error. But I'am not sure if it is the right way.

genotrance commented 1 month ago

This is being fixed in mcurl v8.9.1.0. Px v0.10.0 will use mcurl as the backend.