jakerella / jquery-mockjax

The jQuery Mockjax Plugin provides a simple and extremely flexible interface for mocking or simulating ajax requests and responses
Other
2.11k stars 375 forks source link

Handle 300 status codes better #326

Open jakerella opened 6 years ago

jakerella commented 6 years ago

This came out of PR #79, but that PR is closed for inactivity. We would want to be able to handle 301, 302, 304, 305, and 307 - although this could all be separate issues/PRs.

Adding custom headers to the response is actually easy, but the issue is that XMLHttpRequest is supposed to "silently" follow a 302 (for example) and thus ultimately return the status code from that second request, not the first. We need Mockjax to follow this rule, which essentially means making another ajax call on 302 (or whatever). If that new request is not mocked, then it would go through, but the developer could always mock both the original and redirect endpoints.

jakerella commented 6 years ago

Started working on this in #328 (basic support for 301 and 302)