Home » U++ Library support » U++ MT-multithreading and servers » httprequest fails getting entire url content
Re: httprequest fails getting entire url content [message #57821 is a reply to message #57720] |
Sun, 19 December 2021 15:10   |
 |
mirek
Messages: 14267 Registered: November 2005
|
Ultimate Member |
|
|
aquilarubra wrote on Thu, 02 December 2021 09:37I'm trying to debug.
I see that the source is something like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><result><metadata><count>1</count><limit>20</limit><offset>0</offset></metadata><smsList><sms>...
But I get this in HttpResponse:
{"metadata":{"count":1,"offset":0,"limit":20},"smsList":ERROR: Unexpected end of text.
So, the xml parser is engaged by HttpResponse. I see that the error "Unexpected end of text" is in uppsrc/ide/Designers/Xml.cpp, uppsrc/ide/Xml.cpp, and uppsrc/RichText/ParseQtf.cpp
I tried with request.ContentType("text/plain"), but it is still parsed. Is there any way to bypass that behavior?
Ah, this looks like server returns either JSON or XML, based on Accept, defaulting to JSON unless you specify you want XML.
I think .Accept("application/xml") should fix the problem (no need for the long text).
Alternatively, you can simply use JSON (but probably specify .Accept("application/json") just to be futureproof) and ParseJSON instead. JSON is better format anyway...
[Updated on: Sun, 19 December 2021 15:10] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Tue Aug 26 04:41:45 CEST 2025
Total time taken to generate the page: 0.04063 seconds
|