chimurai / http-proxy-middleware

:zap: The one-liner node.js http-proxy middleware for connect, express, next.js and more
MIT License
10.79k stars 852 forks source link

fix(fix-request-body): support '+json' content-type suffix #1015

Closed howiezhao closed 4 months ago

howiezhao commented 4 months ago

Description

Enhance fixRequestBody method to fix Content-Type includes +json

Motivation and Context

Now, if our Media Type includes +json but does not includes application/json, the fixRequestBody method will not work. For example, the Media Type is application/merge-patch+json.

According to RFC 6838, the + suffix indicates a structured type. Therefore, for the Media Type includes +json, we can directly serialize it to JSON.

This PR fixes the issue where the fixRequestBody method does not work for Media Types includes +json, such as application/merge-patch+json.

How has this been tested?

Unit Test

Types of changes

Checklist:

coveralls commented 4 months ago

Coverage Status

coverage: 97.686%. remained the same when pulling aafb0bd595b701dff8b4c8ee2b1c37d02160ea80 on howiezhao:patch-1 into c8d34f1cb0cb797d497874e9720056784e9070a4 on chimurai:master.

coveralls commented 4 months ago

Coverage Status

coverage: 97.686%. remained the same when pulling 830cbce498dd082396f3d7ed55cfe8e47f2e38f1 on howiezhao:patch-1 into c8d34f1cb0cb797d497874e9720056784e9070a4 on chimurai:master.

chimurai commented 4 months ago

Thank you so much for your time spent on this improvement; with detailed problem description, reference to RFC spec, creating the solution and accompanied by unit-tests.

This is how you do a PR! 🙏

Thanks @howiezhao!