[英]Correct HTTP response header
我正在使用 Safari 來測試我的 C++ 套接字處理程序,我在地址欄中向應用程序發送了一個請求:
http://127.0.0.1:8124/?{%22module%22:%22mdFileIO%22,%22command%22:%22open%22}
在我的應用程序中,我發送了一個響應:
const QString CRLF("\r\n");
QString strContent(strResponse)
,strDtNow(QDateTime::currentDateTime().toUTC().toString("ddd, dd MMM yyyy hh:mm:ss"))
,strHdr = "200 OK" + CRLF
+ "Content-Type: application/json" + CRLF
+ "Content-Length: " + QString::number(strContent.length()) + CRLF
+ "Date: " + strDtNow + " GMT" + CRLF + CRLF;
strResponse = strHdr + strContent;
在上面的“strContent”中包含:
{"ack":"ack","module":"mdFileIO","time":"2020-10-05 18:00:19"}
響應的輸出如下所示:
200 OK\r\nContent-Type: application/json\r\nContent-Length: 62\r\nDate: Mon, 05 Oct 2020 18:25:59 GMT\r\n\r\n{\"ack\":\"ack\",\"module\":\"mdFileIO\",\"time\":\"2020-10-05 18:25:59\"}
標題中有幾個錯誤:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.