-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Override Connector defaultHeaders() in request #430
Comments
Hey @jlevers thats awesome news, nice work on migrating it all over! Would you be able to show me your defaultHeaders on your request, please? The way it's meant to work is the request's properties will always be merged after the connectors, so that they will always take priority. I'm wondering if there's either a bug, or an opportunity to introduce a new interface that prevents merging headers, body etc for these use cases. |
@jlevers It sounds like your issue might be the same as #398. Not the most convenient way, but I wonder if you could maybe try adding a middleware as late as possible and modify the PendingRequest that way. I know @Sammyjo20 already mentions this not working in #398, but maybe try to use a plugin anyway. Worst case you could maybe add the plugin/middleware on the Connector instead, and check the type of the Request the PendingRequest is for, and, if the correct Request, modify the headers on the PendingRequest. Edit: |
@Sammyjo20 thanks for the response :) I don't have any @juse-less good call, middleware should work. I'd like to avoid that and set the headers in the request class if possible, but if that isn't doable then I'll go the middleware route. |
@jlevers typing this on my phone, so bear with me. I think you could do something like this: class MyRequest extends Request
{
public function boot(PendingRequest $request): void
{
$defaultHeaders = array_keys($request->getConnector()->headers()->all());
foreach ($defaultHeaders as $defaultHeader) {
$request->headers()->remove($defaultHeader);
}
}
} |
Ah perfect, that worked! Thanks so much, appreciate it. |
Hi @Sammyjo20,
Thanks for all your awesome work on this package! I've switched over
jlevers/selling-partner-api
to be fully Saloon-based.I'm trying to remove some headers from my OAuth requests, but I can't figure out how to prevent the connector's
defaultHeaders()
from being merged with my request'sdefaultHeaders()
. I see that the merge happens inMergeRequestProperties
, but since that's only accessed byPendingRequest
, I haven't found a great way to get around it.Is there some way to force the headers to be a certain value from inside a request class?
Thanks!
The text was updated successfully, but these errors were encountered: