如何在Firebase托管(node.js)中返回204响应代码 [英] how to return a 204 response code in firebase hosting (node.js)

查看:98
本文介绍了如何在Firebase托管(node.js)中返回204响应代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要一些帮助.我正在尝试使用Android应用程序访问Firebase托管上的文件,该应用程序正在下载.txt文件,出于验证原因,在开始下载之前,它应检查服务器是否可访问,它需要204响应代码(否内容).

Need some help. I am trying to access a file on firebase hosting with an android application, the application is downloading a .txt file and for verification reasons, before starting the download, it should check if the server is reachable, it needs a 204 response code (no content).

我可以在PHP中这样操作:( https://www.yourserver.com/return204.php ):

I can do it in PHP like so: (https://www.yourserver.com/return204.php):

<? php http_response_code(204); ?>

我找到了此链接,但它看起来非常复杂: Firebase HTTP函数,与PHP解决方案相比.我如何在具有Firebase Cloudfunctions的Firebase中做到这一点,或更简单些.谢谢

I found this link, but its looks very complicated: Firebase HTTP Functions, compared to the PHP solution. How can i do it in Firebase with Firebase Cloudfunctions or maybe simpler. Thanks

推荐答案

使用此...

res.status(204).end();

这是全部功能...

exports.MyFunction = functions.https.onRequest((req, res) => {

   res.status(204).end();

});

这篇关于如何在Firebase托管(node.js)中返回204响应代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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