问题
I have a form like this:
<form method="POST" enctype="multipart/form-data">
<input type='submit' name='foo' />
</form>
When that form is submitted, I have some PHP that renders an image:
<img src="http://s3-external-1.amazonaws/bucket/example.jpg?AWSAccessKeyId=foo&Signature=bar&expires=111111" />
The problem is that Internet Explorer 11 (and other versions I believe) are sending a Content-Type: multipart/form-data; boundary=---------------------------7dfcd3b0f0a on that GET request.
When AWS receives the request, they say the signature doesn't match (rightly so).
Few weird quirks:
- If I load the page with HTTPS, the content type is not set to any value (so it works)
- This doesn't happen in any other browsers
- If I have the dev tools open in IE, the content type is not set to any value (so it works)
- If I remove
multipart/form-datathe content type is not set to any value (so it works)
I have tried issuing a cURL request with/without the content-type. It fails with, and succeeds without.
Why would IE be adding a content-type to all GETs on the resulting page after a form submit?
update: It doesn't appear to happen with all forms - but when we submit from a certain part of our application, this happens. Near as I can find, the form on the submitting page is identical, but the form data is put through a different server-side function before the image is rendered. Can't see how this affects IE adding a content-type however.
来源:https://stackoverflow.com/questions/30584155/ie-adding-content-type-multipart-form-data-to-get-requests