HTTP status code returned is 200 instead of 404 (programmatically, not UI-wise)

Summary

When making a request which should return a 404 (e.g., a repository that doesn't exist for a user which does exist), an HTTP status code of 200 is returned even though the UI shows a 404 page. I found this out after wasting half an hour why my link tester wasn't working when I realized it was GitLab's server.

Steps to reproduce

  1. Visit https://gitlab.com/neelkamath/repo-which-does-not-exist in your browser. You will see a 404 page. (This is to show that the UI works, but not programmatically).
  2. If you're on a *nix system, run curl -o /dev/null --silent --write-out '%{http_code}\n' https://gitlab.com/neelkamath/repo-which-does-not-exist. You'll get a 302 (I know I said 404, but that's because you get a 404 in Dart, Python, etc.).
  3. Now let's try it in Python:
    1. Install Python 3
    2. Install dependencies:
      • Windows: pip install requests
      • Other: sudo pip3 install requests
    3. Start the interactive Python console:
      • Windows: python
      • Other: python3
    4. Enter this line: import requests, and then this line: requests.get('https://gitlab.com/neelkamath/repo-which-does-not-exist').status_code. You'll get 404.
  4. Now in Dart:
    1. Install Server Dart 2
    2. In a text editor, create a file main.dart and enter into it:
      main() async {
        final request = await HttpClient().getUrl(Uri.parse('https://github.com/neelkamath/repo-which-does-not-exist'));
        final response = await request.close();
        print(response.statusCode);
      }
    3. Run: dart main.dart
  5. Now repeat all these steps, except replace the host with something else (e.g., change gitlab to github), and you'll get a 404.

What is the current bug behavior?

Incorrect HTTP status code returned for nonexistent resources.

What is the expected correct behavior?

An HTTP status code of 404 returned.

Relevant logs and/or screenshots

https://imgur.com/a/2T7O3qN

https://imgur.com/a/oCwcJVV

Output of checks

I have no idea what this section is, but yea, it's for GitLab.

Results of GitLab environment info

I'm using GitLab CE (the free account) online at GitLab.com (https://gitlab.com) and currently it's running 11.0.

Results of GitLab application Check

Nope.

Possible fixes

Nope.