What I am trying to do is to get a request from a server using fetch in Javascript. The problem is that the answer is coming like a partial-response with xml, so the answer don't come at once, but fetch only give me the first part.
I already tried things like asynchronous things (like await, or then), but I always have only the first part of the answer.
Here is my code :
let response = await fetch(url, {
method: 'POST',
body: // my body
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Connection': 'close',
'Faces-Request': 'partial/ajax',
'X-Requested-With': 'XMLHttpRequest',
'Accept': 'application/xml, text/xml, */*; q=0.01',
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate',
// then cookie, user-agent ...
}});
I also tried using XMLHttpRequest, but I need to use a Cookie header, that I can't use with it.
For the answer, I am expecting something like this (I replaced the personal informations with _) :
<?xml version='1.0' encoding='UTF-8'?>
<partial-response id="j_id1">
<changes>
<update id="form:messages">
<![CDATA[_]]></update>
<update id="form:j_idt117">
<![CDATA[_]]></update>
<update id="form:j_idt133">
<![CDATA[_]]></update>
<update id="form:j_idt228">
<![CDATA[_]]></update>
<update id="j_id1:javax.faces.ViewState:0"><![CDATA[_]]></update>
</changes>
</partial-response>
But I get :
<?xml version='1.0' encoding='UTF-8'?>
<partial-response id="j_id1">
<changes>
<update id="form:j_idt228">
<![CDATA[_]]></update>
<update id="j_id1:javax.faces.ViewState:0"><![CDATA[_]]></update>
</changes>
</partial-response>
So the question is, does fetch have something to help me with it ? I thought first of a wait before beginning to hear for the answer, but I find no documentation on that kind of thing.
Thank you in advance for your help !