开发者

Are there any guidelines to what should NOT go into HTTP headers?

I'm working on an API that sends HTML forms to external AJAX apps.

Woul开发者_Go百科d it be abusing the HTTP headers if I include information such as stylesheets and scripts to use in the headers? I'd like to keep the HTML as clean as possible.


In my point of view: Yes it would.

You better have to keep your transmission protocol (HTTP which is precisely specified in some RFC) as clean as possible than the message transmitted (HTML).

If you are working on creating an API, maybe you should create specifics XML messages that would contain 3 encapsulating parts: one for your stylesheets, one for your scripts and one for your HTML.

That's just an idea, I don't know what your are doing exactly.


This feels like a bad idea.

Although you want to keep the HTML as clean as possible, the HTML block is the 'proper' place to put information on what stylesheets and scripts to include - as they have specific meanings to the HTML.

Putting it in the HTTP headers, although possible using custom header fields ("X-something-or-other"), obfuscates the way in which your app works making things more difficult for future developers to understand, and can inadvertently break should you need to change things later (such as your web server, HTTP client)...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜