3

I am not seeing 200 OK status code next to some of my XHR GET requests in the chrome network logs. Only 200 without the OK. What does this mean and what are the implications? notice the 200 statuses with no OK

Has anyone else faced this issue? I am thinking this is because I also get CORS errors when I fire these get requests as seen here. Do the requests go through?

Ruslan Volyar
  • 33
  • 1
  • 4

1 Answers1

6

It is not chrome dependent. Server sending response to requests. It starts with HTTP protocol version (HTTP/1.1), staus code (200) and status message (for code 200 usually OK). Example response:

HTTP/1.1 200 OK

Another Example

HTTP/1.1 404 Not Found

But it is not defined that response for 200 must be OK and for 404 Not Found. It could be anything. For example another one valid response for code 200.

HTTP/1.1 200 My own status message

You can write simple node.js server which sends My own status message instead of OK.

var http = require('http');

http.createServer(function (req, res) {
    res.statusMessage = "My own status message"; // setting custom status message
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello World\n');
}).listen(1337);

and see it in developer tools

Own status message in developer tools

So the answer is: There are no differences is if the response shows with OK or something other, or nothing. 200 means OK and this the most important information. Status message is only human readable transcription of 200 and it is not important for browser.

Misaz
  • 3,694
  • 2
  • 26
  • 42
  • I take it that this doesn't affect checking OK like this: `fetch('https://someurl') .then(res => { if(res.ok) { return res; } else { throw Error(`Request rejected with status ${res.status}`); } }) .catch(console.error)` ? – JoeTidee Oct 30 '19 at 16:57
  • @joetidee `res.ok` is true when status code is 200 with no matter of status message. – Misaz Oct 30 '19 at 20:07