Questions tagged [http.client]

97 questions
0
votes
1 answer

Bytes and base64 formatting (Python3)

My scripting skills are very basic. I'm trying to adapt a Python 2 snippet I found on here to Python 3. I'm having difficulty formatting this line (I understand it needs a bytes-object but can't get it to work). headers["Authorization"] = "Basic…
0
votes
0 answers

how to upload a file using request.Post in python

I have a python script that need to upload a file using http.client and payload packages. I tried to upload a text file using the parameters of request.post but the system crash and display the below error: Exception has occurred:…
Pyleb Pyl3b
  • 183
  • 3
  • 16
0
votes
1 answer

Python http.client - What is the difference between request and putrequest?

The documentation I've found explaining http.client for Python seems a bit sparse. I want to use it over requests because requests has not worked for our project. So, knowing that I'm using Python's http.client, I'm seeing again and again request…
yodama
  • 659
  • 1
  • 9
  • 21
0
votes
1 answer

How can I use/authenticate msfrpc with python3.x?

Edited: The code below works, and the changes are commented. As noted, with python3 one must prefix the string literals with a "b" to produce an instance of the byte type instead of a Unicode str type. I'm trying to use msfrpc (written in Python…
vdud3
  • 1
  • 3
0
votes
2 answers

How to send data from to local server

I am working on wireless hand gesture bot project. I want to send output of hand gesture to bot. I created a server on raspberry pi using flask and trying to send data through request module but its showing '405 Method Not Allowed Method Not…
0
votes
1 answer

How to use a variable in the python connection.request url

Im trying to read the server names(eg: server1) in a variable and pass it to a url. However, url doesnt take the variable but only the server name hardcoded in it. Is there any way for me to accomplish this? def connect_to_BNAserver(BNAserver): …
Manu SS nair
  • 25
  • 2
  • 7
0
votes
1 answer

using api with http.client to parse imdb movies database

I'm trying to retrieve JSON data from this website: www.themoviedb.org I can only use the http.client and json as libraries. I have a valid API KEY that I don't want to disclose in this question. url =…
rabi26
  • 25
  • 1
  • 4
0
votes
1 answer

Encountered the error when using HTTP client library in Python

I'm using the HTTP client library to send a RESTful GET to a server. This is my code: import http.client conn = http.client.HTTPSConnection("") headers = { 'authorization': "Bearer eyJ0eXAiOiJKV1QiLCJhbG.....JNa0UyT" } conn.request("GET",…
Han Van Pham
  • 462
  • 1
  • 6
  • 24
0
votes
0 answers

Python HTTP request bad character encoding

I am uploading JSON data content to an elasticsearch index using python http.client. I successfully achieve to put the data but I'm having a char issue. Once inserted, special chars like é are outputed like é. Here is the code : import…
DanyDC
  • 73
  • 1
  • 14
0
votes
1 answer

How should I convert the following http.client request in Requests library form ? [Python]

I want to convert the following http.client request code to Requests Library form. I tried doing this, but was stuck thinking where would body and header both be passed in requests.post(url, data=None, json=None, **kwargs). I need to use requests…
Sameer Kumar
  • 93
  • 3
  • 10
0
votes
1 answer

How can I import http.client module in PyCharm 2016.3 and Python 3.6?

I would like to import http.client module in PyCharm 2016.3 (I am using Python 3.6). But, there is no module name "http.client" in the "add" section in "project interpreter" category. How can I import the module? Please help.
신종원
  • 195
  • 1
  • 11
0
votes
1 answer

Problems using HTTPSConnection with http.client

I'm new to Python and especially to web coding. I'm trying to make a program that asks for a name and a surname, and then check on Pipl if there is any result(s). My "tactic" is to directly go to the URL (containing the information) with the result,…
Arthur
  • 11
  • 3
0
votes
0 answers

POST body sent as separate request HttpConnection Python

I have the following code where a POST request is sent to a http server with a JSON request body. The debug prints out 2 requests, showing that the request body is sent as a separate request. import http.client import json if __name__ ==…
Nice Books
  • 1,675
  • 2
  • 17
  • 21
0
votes
1 answer

Python3: http.client with privoxy/TOR making bad requests

I'm trying to use TOR with http.client.HTTPConnection, but for some reason I keep getting weird responses from everything. I'm not really sure exactly how to explain, so here's an example of what I have: class Socket(http.client.HTTPConnection): …
Monchoman45
  • 517
  • 1
  • 7
  • 17
0
votes
1 answer

How to check http status code in python version agnostic way?

I'm writing python code that should run both with python 2.7 and 3.3+ I'm trying to figure out a way to properly check for http status codes and don't reduce my test coverage %. if I write something like: try: import http.client as…
Giovanni Di Milia
  • 13,480
  • 13
  • 55
  • 67