Custom HTTP headers : naming conventions

前端 未结 6 2217
野趣味
野趣味 2020-11-22 09:50

Several of our users have asked us to include data relative to their account in the HTTP headers of requests we send them, or even responses they get from our API.

6条回答
  •  长发绾君心
    2020-11-22 10:07

    Modifying, or more correctly, adding additional HTTP headers is a great code debugging tool if nothing else.

    When a URL request returns a redirect or an image there is no html "page" to temporarily write the results of debug code to - at least not one that is visible in a browser.

    One approach is to write the data to a local log file and view that file later. Another is to temporarily add HTTP headers reflecting the data and variables being debugged.

    I regularly add extra HTTP headers like X-fubar-somevar: or X-testing-someresult: to test things out - and have found a lot of bugs that would have otherwise been very difficult to trace.

提交回复
热议问题