-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
Modify Content-Type header of the response when verifying HTTP provider #870
Comments
Hey, what happens if you set also I would have expected next() to have been called after setting your options, as its a callback see this example https://github.com/pact-foundation/pact-js#modify-requests-prior-to-verification-request-filters
|
I tried but same result ! As suggested, I forked the pact-js repository and modified an example in order to reproduce the issue. You can find my fork here. To reproduce it :
|
@YOU54F , any insight on this one ? |
Can I ask - why do you want to change the content type header of the provider? This is a fairly crucial header as far as matching is concerned, so overriding it is quite dangerous. I'm not sure why we can't override the content-type header here, it's probably something to do with the way express works. You can certainly add others. I don't have time to look into this specific issue. If you really need to do this and can't find a way to modify the current Pact JS code / use the express interface provided, I'd suggest you add a test only middleware on your provider code base and modify it there (or roll your own proxy). |
That's indeed a good question ! In fact, this api will run in an AWS lambda. Consequently, I deploy the code on localstack during my CI step and run the Pact contract on it. |
Glad to hear! I'm going to leave this open as a feature request in the meantime. |
@nicolasariza this is a different issue to the one reported here. You could add a regex matcher on the response header that was case insensitive or ignored the charset component. |
Hello everyone,
Seems there is an issue when you try to modify the 'Content-Type' header using a requestFilter.
Software versions
Expected behaviour
The test should pass, the 'Content-Type' header of the response should be set to 'application/json'.
Actual behaviour
Expected header "content-type" to equal "application/json", but was "text/html; charset=utf-8".
It seems there is an issue with this content-type header. I can add any header but this one.
Steps to reproduce
I added a requestFilter in the options of the
Verifier
constructor.Logs :
You can see that the
test
header has been added but the content-type header hasn't been set correctly.Thanks in advance for your answer.
The text was updated successfully, but these errors were encountered: