OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

What's the correct way to use a unix domain socket in requests framework?

  • Thread starter Thread starter Luis Masuelli
  • Start date Start date
L

Luis Masuelli

Guest
Usually, doing a post request using requests framework is done by:

Code:
payload = {'key1': 'value1', 'key2': 'value2'}
r = requests.post("http://httpbin.org/post", data=payload)

But: How do I connect to a unix socket instead of doing a TCP connection?

On a related note, how to encode domain path in the URL?

  • libcurl allows application to supply own socket on which to perform request
  • LDAP invented own scheme ldapi where socket name is %-encoded in host field
  • httpie uses http+unix scheme and %-encoded path in host field

These are some examples, but is there an RFC or established best practice?
<p>Usually, doing a post request using <a href="http://docs.python-requests.org/en/latest/">requests</a> framework is done by:</p>

<pre><code>payload = {'key1': 'value1', 'key2': 'value2'}
r = requests.post("http://httpbin.org/post", data=payload)
</code></pre>

<p>But: How do I connect to a unix socket instead of doing a TCP connection?</p>

<p>On a related note, how to encode domain path in the URL?</p>

<ul>
<li>libcurl allows application to supply own socket on which to perform request</li>
<li>LDAP invented own scheme <code>ldapi</code> where socket name is %-encoded in host field</li>
<li><code>httpie</code> uses <code>http+unix</code> scheme and %-encoded path in host field</li>
</ul>

<p>These are some examples, but is there an RFC or established best practice?</p>
 

Latest posts

Top