• The_Decryptor@aussie.zone
    link
    fedilink
    English
    arrow-up
    2
    ·
    7 hours ago

    Well no, the HTTP error codes are about the entire request, not just whether or not the actual header part was received and processed right.

    Like HTTP 403, HTTP only has a basic form of authentication built in, anything else needs the server to handle it externally (e.g. via session cookies). It wouldn’t make sense to send “HTTP 200” in response to trying to access a resource without being logged in just because the request was well formed.

    • porkloin@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      5 hours ago

      Many GraphQL and gRPC APIs do exactly that and return HTTP 200 even if the request didn’t auth.

      Just because you are heavily biased toward using HTTP status for application layer errors doesn’t make it right. It is so wildly common that people can’t imagine it working another way, and I get that.

      But it’s not “wrong” to do application layer auth status codes and apply no transport layer auth status codes It’s just a different paradigm than most devs are used to.

      • The_Decryptor@aussie.zone
        link
        fedilink
        English
        arrow-up
        1
        ·
        55 minutes ago

        Ehh, that really feel like “But other people do it wrong too” to me, half the 4xx error codes are application layer errors for example (404 ain’t a transport layer error, neither is 403, 415, 422 or 451)

        It also complicates actually processing the request as you’ve got to duplicate error handling between “request failed” and “request succeeded but actually failed”. My local cinema actually hits that error where their web frontend expects the backend to return errors, but the backend lies and says everything was successful, and then certain things break in the UI.