Skip to content

client port should be passed to httplib as integer not string #69

@bcavagnolo

Description

@bcavagnolo

When I pass an unresolved hostname to client.connect, I get an exception:

<snip>
  File "/usr/local/lib/python2.7/dist-packages/splunklib/client.py", line 288, in connect
    return Service(**kwargs).login()
  File "/usr/local/lib/python2.7/dist-packages/splunklib/binding.py", line 751, in login
    password=self.password)
  File "/usr/local/lib/python2.7/dist-packages/splunklib/binding.py", line 1079, in post
    return self.request(url, message)
  File "/usr/local/lib/python2.7/dist-packages/splunklib/binding.py", line 1096, in request
    response = self.handler(url, message, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/splunklib/binding.py", line 1195, in request
    connection.request(method, path, body, head)
  File "/usr/lib/python2.7/httplib.py", line 958, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 992, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 954, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 814, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 776, in send
    self.connect()
  File "/usr/lib/python2.7/httplib.py", line 1157, in connect
    self.timeout, self.source_address)
  File "/usr/local/lib/python2.7/dist-packages/gevent/socket.py", line 637, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/local/lib/python2.7/dist-packages/gevent/socket.py", line 737, in getaddrinfo
    raise gaierror(EAI_SERVICE, 'Servname not supported for ai_socktype')
socket.gaierror: [Errno -8] Servname not supported for ai_socktype

binding.py:hander.request extracts the port as a string from a url argument. This gets passed down the stack eventually (on my system, anyway) to gevent/socket.py. getaddrinfo sees the port as a string and tries to look it up in /etc/services instead of accepting it as an integer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions