Giter Club home page Giter Club logo

Comments (1)

mastak avatar mastak commented on June 25, 2024

Probably httplib2/http have some issue. I tried to run row requests with httplib2 and request,
and variant with request always return success,
httplib2 always failed.

import json
import logging

import coloredlogs
coloredlogs.install(logging.DEBUG)


HOST = 'rabbitmq'
PORT = '15672'
USER = 'admin'
PASSW = 'admin'
VHOST = 'some'
DATA = json.dumps({"configure": '.*', "read": '.*', "write": '.*'})
HEADERS = {"Content-Type": "application/json"}
URL = 'http://192.168.155.128:15672/api/permissions/some/admin'


def request():
    import requests

    requests.put(URL, auth=(USER, PASSW), data=DATA, headers=HEADERS)
request()


def http():
    import httplib2

    client = httplib2.Http()
    client.add_credentials(USER, PASSW)
    client.request(URL, "PUT", DATA, headers=HEADERS)
http()

httplib2 traceback:

Traceback (most recent call last):
  File "./tmp.py", line 31, in <module>
    http()
  File "./tmp.py", line 30, in http
    client.request(URL, "PUT", DATA, headers=HEADERS)
  File "/usr/local/lib/python3.5/site-packages/httplib2/__init__.py", line 1314, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/usr/local/lib/python3.5/site-packages/httplib2/__init__.py", line 1075, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers, )
  File "/usr/local/lib/python3.5/site-packages/httplib2/__init__.py", line 988, in _conn_request
    conn.request(method, request_uri, body, headers)
  File "/usr/local/lib/python3.5/http/client.py", line 1083, in request
    self._send_request(method, url, body, headers)
  File "/usr/local/lib/python3.5/http/client.py", line 1128, in _send_request
    self.endheaders(body)
  File "/usr/local/lib/python3.5/http/client.py", line 1079, in endheaders
    self._send_output(message_body)
  File "/usr/local/lib/python3.5/http/client.py", line 913, in _send_output
    self.send(message_body)
  File "/usr/local/lib/python3.5/http/client.py", line 885, in send
    self.sock.sendall(data)
BrokenPipeError: [Errno 32] Broken pipe

Any idea? :)

from pyrabbit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.