Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make an http request without getting back an http response in Python?

Tags:

python

http

I want to send it and forget it. The http rest service call I'm making takes a few seconds to respond. The goal is to avoid waiting those few seconds before more code can execute. I'd rather not use python threads I'll use twisted async calls if I must and ignore the response.

like image 797
user420814 Avatar asked Aug 15 '10 05:08

user420814


People also ask

Can a HTTP response is lost?

They get lost because the internet is a big place and sometimes packets get dropped or servers get overloaded.

Which of the Python libraries makes it very easy to make HTTP requests from Python?

Libraries in Python to make HTTP Request There are many libraries to make an HTTP request in Python, which are httplib, urllib, httplib2 , treq, etc., but requests are the simplest and most well-documented libraries among them all.

Is HTTP POST request allowed to send back a response body?

Yes you can, and the specification is clear about what you can do and how to do it: The action performed by the POST method might not result in a resource that can be identified by a URI.

How do you make a HTTP POST request in Python?

The post() method sends a POST request to the specified url. The post() method is used when you want to send some data to the server.


1 Answers

You are going to have to implement that asynchronously as HTTP protocol states you have a request and a reply.

Another option would be to work directly with the socket, bypassing any pre-built module. This would allow you to violate protocol and write your own bit that ignores any responses, in essence dropping the connection after it has made the request.

like image 174
Josh K Avatar answered Sep 30 '22 15:09

Josh K