When executing a GCF triggered by an Http Request, I encounter the issue of receiving unnecessary headers along with my custom message. Here is a list of headers that are included:
HTTP/1.1 200 OK
Server: nginx
Content-Type: application/json; charset=utf-8
x-powered-by: Express
cache-control: private
Strict-Transport-Security: max-age=31556926; includeSubDomains; preload
etag: W/"19-7046833f"
function-execution-id: nx88bs3fra23
x-cloud-trace-context: 302401ba6a3c3d461c32dc7e4825c54d;o=1, 302401ba6a3c3d461c32dc7e4825c54d
Content-Length: 25
Accept-Ranges: bytes
Date: Wed, 05 Jul 2017 01:48:23 GMT
Via: 1.1 varnish
Connection: keep-alive
X-Served-By: cache-lax8651-LAX
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1499219281.929840,VS0,VE22189
As I am making this request from a 3G module and not a web browser, all these headers are redundant for my purpose. The code snippet used to get this response is as follows:
'use strict';
exports.myfunction = functions.https.onRequest((req, res) => {
admin.database().ref('/root').once('child_changed', (snapshot) =>{
res.send(snapshot.val());
});
});
I have explored the response documentation and found the res.set(field [, value]) method.
Is there any way to remove these unwanted headers sent automatically by the server?