0

I have a flask server which get requests, and I want to send that raw request to a different flask server that is in charge of logging all of the requests made into my network.

I am trying to pass the original request (as is) to the logger flask application, but I am running into some trouble.

I tried sending request.dict, but it does not contain all the original data.

I also tried using pickle on the request object, but I get an error while trying to dump it. my code:

import pickle
@app.route("/login", methods=['GET', 'POST'])
    def login():
        data = {'pickled': pickle.dumps(request)}

Error:

_pickle.PicklingError: args[0] from newobj args has the wrong class

Does anyone has any suggestions on how can I do such thing?

  • Do you get that error during the dump or when trying to unpickle the result on the other end? – mousetail Aug 24 '23 at 12:26
  • 1
    Does this answer your question? [Proxying to another web service with Flask](https://stackoverflow.com/questions/6656363/proxying-to-another-web-service-with-flask) Using the requests library, it re-sends the request to another service. Your service can they do with that what you want. It's not exactly the raw request but it may be close enough? – JeffUK Aug 24 '23 at 12:42
  • @JeffUK, it is close to what I want to do, but I also need all the information of the client who made the original request, which I don't when acting as a proxy. – Naftali Shtern Aug 27 '23 at 07:09

0 Answers0