阅读HTTP请求标头,并修改Apps脚本Web应用程序的响应标头 [英] Read HTTP request headers, and modify response headers of an Apps Script web app

查看:88
本文介绍了阅读HTTP请求标头,并修改Apps脚本Web应用程序的响应标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以修改HTTP响应标题以添加Cookie和额外信息吗?

解决方案

您无法在部署为应用程序脚本的应用程序中读取或设置HTTP标头一个Web应用程序。您被限制为分别读取GET / POST的查询字符串或帖子值。回复时,您只能返回内容和MIME类型(仅限于少数类型)



这是因为这些脚本是在Google.com网域中投放的,因此您无法设置/获取可能因恶意原因而使用的Cookie。 然而,如果您正在使用 UrlFetch , Apps脚本应用程序进行呼出呼叫,您可以更多地控制HTTP标头


Can I modify the HTTP response headers to add cookies and extra information? Also I'm having troubles reading the request headers.

解决方案

You cannot read or set HTTP Headers in a Apps Script app deployed as a web app. You are restricted to reading the query string or the post values for GET/POST respectively. When responding you can only return the content and the MIME type (restricted to a few types)

This is because the scripts are served off the Google.com domain and you should not have ways to set/get cookies that could potentially be used for malicious reasons.

However, if you are using UrlFetch within an Apps Script app to make outbound calls, you have much more control of the HTTP headers

这篇关于阅读HTTP请求标头,并修改Apps脚本Web应用程序的响应标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆