Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
### **User description** [TT-13021]Transfer encoding fix (#6770) ### **User description** <!-- Provide a general summary of your changes in the Title above --> TASK: https://tyktech.atlassian.net/browse/TT-13021 ## Description <!-- Describe your changes in detail --> ## Related Issue <!-- This project only accepts pull requests related to open issues. --> <!-- If suggesting a new feature or change, please discuss it in an issue first. --> <!-- If fixing a bug, there should be an issue describing it with steps to reproduce. --> <!-- OSS: Please link to the issue here. Tyk: please create/link the JIRA ticket. --> ## Motivation and Context <!-- Why is this change required? What problem does it solve? --> ## How This Has Been Tested <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why ___ ### **PR Type** Bug fix, Enhancement ___ ### **Description** - Fixed an issue with reading and resetting the request body in the URL rewrite middleware to ensure downstream handlers can process it correctly. - Enhanced regex matching logic in the URL rewrite middleware, including improved context data handling. - Extended the tracing functionality to support OAS definitions by adding a new field in the trace request structure and implementing extraction logic. - Improved error handling for malformed or incomplete trace requests. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix</strong></td><td><table> <tr> <td> <details> <summary><strong>mw_url_rewrite.go</strong><dd><code>Improve request body handling and regex matching in URL rewrite </code><br><code>middleware</code></dd></summary> <hr> gateway/mw_url_rewrite.go <li>Added error handling for reading the request body.<br> <li> Reset the request body to allow downstream handlers to read it.<br> <li> Enhanced regex matching logic and updated context data handling.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6770/files#diff-84a6a5c810334aaa8702669f2aebf0284f116d83e8a55ec9d1d5b8bae87f1be6">+20/-1</a> </td> </tr> </table></td></tr><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>tracing.go</strong><dd><code>Extend tracing functionality to support OAS definitions</code> </dd></summary> <hr> gateway/tracing.go <li>Extended trace request structure to include OAS definitions.<br> <li> Added logic to extract and log OAS definitions into API definitions.<br> <li> Improved error handling for missing or malformed trace requests.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6770/files#diff-0069987d730b02812808925a17e1434ca7558a4dfc8661beb27ccd11afb8c77d">+8/-2</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information --------- Co-authored-by: lghiur <[email protected]> [TT-13021]: https://tyktech.atlassian.net/browse/TT-13021?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ ___ ### **PR Type** Bug fix, Enhancement ___ ### **Description** - Fixed an issue with reading and resetting the request body in the URL rewrite middleware to ensure downstream handlers can process it correctly. - Enhanced regex matching logic in the URL rewrite middleware, including improved context data handling. - Added test cases to validate payload trigger functionality and ensured reading payload for triggers does not break the request. - Updated JSON validation logic to improve request body handling by replacing `ioutil.ReadAll` with `io.ReadAll`. - Extended the tracing functionality to support OAS definitions by adding a new field in the trace request structure and implementing extraction logic. - Improved error handling for malformed or incomplete trace requests. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix</strong></td><td><table> <tr> <td> <details> <summary><strong>mw_url_rewrite.go</strong><dd><code>Improve request body handling and regex matching in URL rewrite </code><br><code>middleware</code></dd></summary> <hr> gateway/mw_url_rewrite.go <li>Improved error handling for reading the request body.<br> <li> Reset the request body to allow downstream handlers to read it.<br> <li> Enhanced regex matching logic and updated context data handling.<br> <li> Updated context data with modified map after regex operations.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6782/files#diff-84a6a5c810334aaa8702669f2aebf0284f116d83e8a55ec9d1d5b8bae87f1be6">+18/-2</a> </td> </tr> <tr> <td> <details> <summary><strong>mw_validate_json.go</strong><dd><code>Update JSON validation to improve request body handling</code> </dd></summary> <hr> gateway/mw_validate_json.go <li>Replaced <code>ioutil.ReadAll</code> with <code>io.ReadAll</code> for reading request body.<br> <li> Added <code>nopCloseRequestBody</code> to handle request body reset.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6782/files#diff-0f0c6b9ac40c5e01908a5b24b1d03111c8d8b4dbc1ddc0251d17c3c1b5328ab5">+3/-2</a> </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>mw_url_rewrite_test.go</strong><dd><code>Add tests for payload triggers and URL rewrite functionality</code></dd></summary> <hr> gateway/mw_url_rewrite_test.go <li>Added test cases to validate payload trigger functionality.<br> <li> Ensured reading payload for triggers does not break the request.<br> <li> Enhanced test coverage for URL rewrite triggers.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6782/files#diff-b5d21238a0fb61d153d824ded42acf4d4a553e962ca8fa015bbff31027b428a5">+48/-5</a> </td> </tr> </table></td></tr><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>tracing.go</strong><dd><code>Extend tracing functionality to support OAS definitions</code> </dd></summary> <hr> gateway/tracing.go <li>Extended trace request structure to include OAS definitions.<br> <li> Added logic to extract and log OAS definitions into API definitions.<br> <li> Improved error handling for malformed trace requests.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6782/files#diff-0069987d730b02812808925a17e1434ca7558a4dfc8661beb27ccd11afb8c77d"></a></td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information Co-authored-by: andrei-tyk <[email protected]>
- Loading branch information