I am attempting to transmit a GET request to a server to update particular json values. I have been making use of these similar posts to do so:
Python-Scapy or the like-How can I create an HTTP GET request at the packet level
Filter HTTP Get requests packets using scapy
How can I alter the JSON object and override the values highlight in the image that are being sent?
Related
I would like to stream data from a python client to an HTTP2 POST request. Meaning, streaming from the client to the server.
I found an example on the httpx documentation that shows how to stream from a response. I would like to do the opposite, stream up to the server in a POST request.
I'm coming from a javascript background, in which the request object is a writeable stream, so I can do something like this:
process.stdin.pipe(request)
// or
pipeline(process.stdin, request)
How can I achieve something similar in Python?
Can I send a http response to a specific requestLine outside the function I received the request in it.
As an example I receive the request then pass this request to some functions and I want to send a response to this request, if there is allowed?
If you're going to split the path your program is taking, so it's doing two different things at the same time, then you'll need to utilize control-flow constructs that do this like threads/processes/events/async.
You might want to look at Celery (http://www.celeryproject.org/) and Jobtastic (http://policystat.github.io/jobtastic/).
I have Python-Eve running with MongoDB on a Ubuntu VM. I am trying to write an api to handle POST requests from an Iridium RockBLOCK modem. I have tested the API with Chrome Postman, and am able to successfully POST data.
When I try and send messages from my RockBLOCK I get 422 error messages on the VM. I am pretty sure this is because the RockBLOCK is not able to handle XML or JSON data, and is set up to simply look for an HTTP 200 response.
So how would I setup eve to respond with solely HTTP 200 when the POST request is received?
API Format taken from RockBLOCK Web Services Guide.
The 422 is returned from Eve when a validation error occurs. I would look into your request payload and make sure it adheres to validation rules. A typical example of a response like this would be when you have a unique rule for a field, and a POST comes in with an already used value for that field.
So how would I setup eve to respond with solely HTTP 200 when the POST request is received?
Right now you can disable either JSON or XML responses by respectively setting JSON = False or XML = False, but not both. Since Eve is a Flask application you could look into changing the response on the flight but again, given the error you are getting I don't think that is the problem you are facing right now.
I am attempting to work with large packet captures from wireshark that have been output in pdml format. These captures are then loaded into python using the lxml library to traverse over them. The issue I am having is that I can pull out information regarding a single HTTP response packet and then I need a way to associate this with its HTTP request packet.
The current solution I was thinking of implementing is to search for an HTTP request packet that is part of the same TCP stream as the response, however this seems like an inefficient solution to the problem, having to continually separate out TCP streams and then search through them for the request packet.
Is there a simple way to associate response packets with requests that I am missing?
Best solution I have come up with thus far is to use xpath under the assumption that each TCP connection only contains one request/response pair.
#Get the stream index from the packet
streamIndex = packet.xpath('proto/field[#name="tcp.stream"]')[0].attrib['show']
#Use that stream index to get the matching response packet
return packet.xpath('/pdml/packet[proto/field[#name="tcp.stream" and #show="' + streamIndex + '"] and proto/field[#name="http.request.full_uri"]]')[0]
I have an app installed on Google Appengine running on Python code. It has a request handler and a built-in database, which I update via something like this:
http://appname.appspot.com/?type=update&service=test_name&url=..........
I only want the database to update, if the client accessing the python app has a certain HTTP header, and bounce all other requests. How do I request a list of the HTTP headers and check if the list contains a certain header string within?
See http://code.google.com/appengine/docs/python/tools/webapp/requestclass.html#Request_headers
Basically
self.request.headers
is a dictionary-like object that holds the request headers.
within your handler self.request holds all the request info, including headers.