Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding extra header values to HTTP request #1047

Open
FatherFil opened this issue Jun 18, 2021 · 6 comments
Open

Adding extra header values to HTTP request #1047

FatherFil opened this issue Jun 18, 2021 · 6 comments
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap

Comments

@FatherFil
Copy link

The emails we send using SendGrid usually contain a lot of bona-fide links and this has occasionally tripped the security filters at SendGrid, resulting in our emails not being sent. Once we confirmed with SendGrid Security Team that our links are okay and not spam we were asked to include a special key in the header of our API requests.

After much to and fro between our dev team and the SendGrid support team, on how best to do this, and exactly why it would be bad practice to fork the official repo and mangle the code to add the key in manually, I wondered whether it was possible to add in the ability to push a new header key value pair into the base HTTP request in sendgrid\lib\BaseSendGridClientInterface.php

I'm happy to craft something and submit a pull request but I wanted to check first that:

  1. that's acceptable for this repo/package
  2. there isn't a function I'm missing that does this already

Many thanks,

Phil

@thinkingserious
Copy link
Contributor

Hello Phil!

How about the addHeader function (example)?

With best regards,

Elmer

@thinkingserious thinkingserious added status: waiting for feedback waiting for feedback from the submitter type: question question directed at the library labels Jun 22, 2021
@FatherFil
Copy link
Author

Hi Elmer,

Thanks for the reply - we've been using the addHeader function for the past six months, but according to the SendGrid security team it's not appearing in the request header they're receiving. We changed to addGlobalHeader and that got the same response from the security team after a few weeks.

I couldn't see how either addHeader or addGlobalHeader actually affected the header, which looks like it is constructed in BaseSendGridClientInterface->__construct() - however I suspect my knowledge of the library is holding me back here.

Best wishes,

Phil

@thinkingserious
Copy link
Contributor

Hello @FatherFil,

When you use addHeader or addGlobalHeader, do you see the headers when you examine the source for the raw email?

@FatherFil
Copy link
Author

Hi @thinkingserious ,

When I tried using those functions, yes, I could see the headers in the email header, however the issue is not with the email headers, but the HTTP request headers.

The SendGrid security team are asking me to add extra values to the HTTP request header in order to prove the request is genuine and allow me to bypass some of their restrictions. I believe the addHeader and addGlobalHeader affect the email header, not the request header.

@thinkingserious
Copy link
Contributor

Thanks for the elaboration @FatherFil,

I think adding a helper to pass in additional headers to the Client would be a worthy addition to this library and we would appreciate your PR. Here is an example of setting the request headers. Thank you!

@FatherFil
Copy link
Author

@thinkingserious Thank you. And for the example of setting the request headers.

@shwetha-manvinkurke shwetha-manvinkurke added status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap and removed status: waiting for feedback waiting for feedback from the submitter type: question question directed at the library labels Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

No branches or pull requests

3 participants