Tuesday, 6 June 2017

Intercept sending request to change a header with request library

I am using the infamous request library to send requests. One of those requests requires me to send the header multipart/mixed; boundary={myboundary}.

Request is using the form-data library for such requests but it does not set the Content-Type header properly. Therefore I would need to set it like this:

let req = request.post({url: "https://..."}, formData: formData)
req.setHeader('Content-Type', `multipart/mixed; boundary=${req.form().getBoundary()}`)

Sadly I can't add/alter any headers after firing the request. Therefore I want to know whether there is a way to intercept the sending so I can change the header?



via Hedge

No comments:

Post a Comment