CopyPastor

Detecting plagiarism made easy.

Score: 0.9776420485588813; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-09-07
by yuvaraj jonna

Original Post

Original - Posted on 2011-12-20
by Dobes Vandermeer



            
Present in both answers; Present only in the new answer; Present only in the old answer;

To answer your main question, the CORS spec only requires the OPTIONS call to precede the POST or GET if the POST or GET has any non-simple content or headers in it.
Content-Types that require a CORS pre-flight request (the OPTIONS call) are any Content-Type _except the following_:
1. `application/x-www-form-urlencoded` 2. `multipart/form-data` 3. `text/plain`
Any other Content-Types apart from those listed above will trigger a pre-flight request.
As for Headers, any Request Headers _apart from the following_ will trigger a pre-flight request:
1. `Accept` 2. `Accept-Language` 3. `Content-Language` 4. `Content-Type` 5. `DPR` 6. `Save-Data` 7. `Viewport-Width` 8. `Width`
Any other Request Headers will trigger the pre-flight request.
To answer your main question, the CORS spec only requires the OPTIONS call to precede the POST or GET if the POST or GET has any non-simple content or headers in it.
Content-Types that require a CORS pre-flight request (the OPTIONS call) are any Content-Type _except the following_:
1. `application/x-www-form-urlencoded` 2. `multipart/form-data` 3. `text/plain`
Any other Content-Types apart from those listed above will trigger a pre-flight request.
As for Headers, any Request Headers _apart from the following_ will trigger a pre-flight request:
1. `Accept` 2. `Accept-Language` 3. `Content-Language` 4. `Content-Type` 5. `DPR` 6. `Save-Data` 7. `Viewport-Width` 8. `Width`
Any other Request Headers will trigger the pre-flight request.
So, you could add a custom header such as: `x-Trigger: CORS`, and that should trigger the pre-flight request and hit the OPTIONS block.
See [MDN Web API Reference - CORS Preflighted requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Preflighted_requests)

        
Present in both answers; Present only in the new answer; Present only in the old answer;