Skip to content

Conversation

@1911860538
Copy link
Contributor

@1911860538 1911860538 commented Nov 8, 2025

This PR makes several improvements to JSONP handling:

Content Type Correction for JsonpJSON

  • Modified JsonpJSON.Render to use 'application/json; charset=utf-8' when callback is empty
  • This aligns with JSONP definition which requires a callback function wrapper
  • Ensures proper content type matching for the actual data format being returned

Context.JSONP Method Simplification

  • Refactored Context.JSONP to use a cleaner, one-line implementation
  • Removed duplicate code and redundant condition checking

Test Updates

  • Added TestRenderJsonpJSONWithEmptyCallback to verify correct content type

These changes improve code maintainability
while ensuring JSONP responses conform to proper standards.
According to JSONP (JSON with Padding) definition,
it is a technique for sending JSON data
without worrying about cross-domain issues
by wrapping the JSON response in a JavaScript function call.

Ref #1438

@codecov
Copy link

codecov bot commented Nov 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.96%. Comparing base (3dc1cd6) to head (a14cf7c).
⚠️ Report is 202 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4427      +/-   ##
==========================================
- Coverage   99.21%   98.96%   -0.25%     
==========================================
  Files          42       44       +2     
  Lines        3182     2898     -284     
==========================================
- Hits         3157     2868     -289     
- Misses         17       19       +2     
- Partials        8       11       +3     
Flag Coverage Δ
?
--ldflags="-checklinkname=0" -tags sonic 98.95% <100.00%> (?)
-tags go_json 98.88% <100.00%> (?)
-tags nomsgpack 98.94% <100.00%> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 ?
go-1.24 98.96% <100.00%> (?)
go-1.25 98.96% <100.00%> (?)
macos-latest 98.96% <100.00%> (-0.25%) ⬇️
ubuntu-latest 98.96% <100.00%> (-0.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@1911860538
Copy link
Contributor Author

@appleboy CC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant