What is the proper HTTP response to send for requests that require SSL/TLS

后端 未结 5 1544
长情又很酷
长情又很酷 2020-12-03 16:38

I\'m designing an RESTful API where some calls are public over HTTP, and some require an API key and encryption over HTTPS. I\'m deliberating on what response code should b

5条回答
  •  难免孤独
    2020-12-03 17:07

    I cannot say if this is broadly accepted by HTTP clients, but speaking strictly RFC, the server should respond with:

    HTTP/1.1 426 Upgrade Required
    Upgrade: TLS/1.0, HTTP/1.1
    Connection: Upgrade
    

    Source:
    http://tools.ietf.org/html/rfc2817#section-4.2

提交回复
热议问题