Can I modify the HTTP response headers to add cookies and extra information? Also I'm having troubles reading the request headers.
While you can't ready any headers of HTML response in JS, you can read Server-Timing header, and you can pass arbitrary key-value data through it.
Modify Header Value (HTTP Headers) is an extension that can add, modify or remove an HTTP-request-header for all requests on a desired website or URL. This Addon is very useful if you are an App developer, website designer, or if you want to test a particular header for a request on a website.
An HTTP header is a field of an HTTP request or response that passes additional context and metadata about the request or response. For example, a request message can use headers to indicate it's preferred media formats, while a response can use header to indicate the media format of the returned body.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With