scripting / xml-rpc

XML-RPC client and server in JavaScript.
MIT License
61 stars 28 forks source link

Make access to the HTTP Request Headers easier #15

Open soapdog opened 2 years ago

soapdog commented 2 years ago

At the moment, the callback executed when a XML-RPC Server receives a request exposes the original request object as its last argument. That is very useful, but it adds a bit of friction when attempting to access HTTP Request Headers. It would be great if the headers could be added to that callback as another argument before the original final HTTP Request argument. Ideally the headers could be exposed as a simple object.

My reasoning for wanting easy access to them is because they help with developing authentication workflows.

scripting commented 2 years ago

Thanks for these reports. It would be helpful if when reporting something like this you provided a pointer to the code you're writing about. It would save me some time, and would help me be sure I'm looking at the right part of the code.

soapdog commented 2 years ago

oh sorry, I should've added some references. What meant is that it would be great if this object here also included the request HTTP headers:

https://github.com/scripting/xml-rpc/blob/965c38ab91c9028c67172dfd19fdc3c2b73a982f/xmlrpc.js#L507-L513

The low-level request included has headers, but using them has some friction. Adding them as an extra property would make it easier. My use-case is to use authentications similar to OAuth and other tokens that are passed via headers instead of arguments to the RPC call.

scripting commented 2 years ago

Thanks for the pointer to the code in question.

Two more questions --

  1. What does "has some friction" mean?

  2. You were going to submit a pull request for this -- what code were you proposing to change/add?