ios - How to send two reponses to a GCDWebServer request
问题描述
I'm using GCDWebServer
's addDefaultHandlerForMethod:@"GET"
and sending an NSData response via
GCDWebServerDataResponse responseWithData:contentType:@"application/octet-stream"
The user's browser receives a file which it saves in the Download folder. So far, so good. I also want to send a GCDWebServerDataResponse responseWithHTML:
to show additional information to the user.
Given one GET request, is there a way to send two responses, one with data and one with HTML?
解决方案
This is not possible due to the way HTTP is designed to work: 1 request = 1 response. If you want an HTML page and also a file to be downloaded, return a first response for the HTML page, then from this page itself, using JavaScript or a redirect, now do the download.
推荐阅读
- javascript - 找出每个子数组中任意一个元素可以形成的最大乘积
- ansible - 使用 ansible _mount 和 json_jquery 的剧本任务引发错误
- oracle - DBA 目录无法访问
- c# - 类型初始化异常 -filenotfoundexception
- vb.net - 如果控件的 enabled 属性为 false,选项卡索引如何工作
- docker - 当我的 Jest 单元测试在 Docker 中失败时,如何获得测试报告?
- android - Android : 在 android Q 中合并音频和视频文件
- javascript - RoR:按钮按下时简单无刷新
- android - 在Redmi 7A上启动相机拍照时应用程序崩溃
- android - Android:ListPreference 让应用退出全屏模式