I am producing a HTTP response from an Qt 5.15.2 application, the response is typically something like:
HTTP/1.1 200 OK
Server: XMLMPAM
Access-Control-Allow-Origin: *
Date: Sun, 24 Jan 2021 07:56:45 GMT
Content-Length: 65
Connection: Closed
Content-Type: text/html; charset=utf-8
<!DOCTYPE html><html><body>{%22msgType%22:%22hb%22}</body></html>
Here is the code that produces this:
static const QString scstrLineTerm("
");
QString strWrapper("<!DOCTYPE html><html><body>" + arybytData + "</body></html>")
,strDateTime(dtUTC.toString("ddd, dd MMM yyyy hh:mm:ss") + " GMT")
,strDataLength(QString::number(strWrapper.length()))
,strHTTP = QString("HTTP/1.1 200 OK%1"
"Server: XMLMPAM%2"
"Access-Control-Allow-Origin: *%3"
"Date: %4%5"
"Content-Length: %6%7"
"Connection: Closed%8"
"Content-Type: text/html; charset=utf-8%9"
"%10%11"
"%12").arg(scstrLineTerm
,scstrLineTerm
,scstrLineTerm
,strDateTime, scstrLineTerm
,strDataLength, scstrLineTerm
,scstrLineTerm
,scstrLineTerm
,scstrLineTerm, scstrLineTerm
,strWrapper);
This is the URL from the browser that goes with the response:
http://localhost:8123/?{%22msgType%22:%22hb%22}
The browser gets the response:
{%22msgType%22:%22hb%22}
What I want is a response without the escape codes so it looks like:
{"msgType":"hb"}
question from:
https://stackoverflow.com/questions/65868264/http-headers-and-data-response-how-to-decode-in-data 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…