Skip to content

Commit

Permalink
dom: fix HttpRes.contentBuf and beef up documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
briansfrank committed Apr 25, 2024
1 parent 19b0f36 commit 2dd631b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/dom/es/HttpReqPeer.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class HttpReqPeer extends sys.Obj {
if (isText)
res.content(xhr.responseText);
else if (xhr.responseType == "arraybuffer")
res.contentBuf(sys.MemBuf.__makeBytes(res.content));
res.contentBuf(sys.MemBuf.__makeBytes(xhr.response));

const all = xhr.getAllResponseHeaders().split("\n");
for (let i=0; i<all.length; i++)
Expand Down Expand Up @@ -152,4 +152,5 @@ class HttpReqPeer extends sys.Obj {
// send POST request
self.send("POST", data, f);
}
}
}

6 changes: 4 additions & 2 deletions src/dom/fan/HttpReq.fan
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ class HttpReq

** The type of data contained in the response. It also lets the
** author change the response type. If an empty string is set as
** the value, the default value of '"text"' is used.
@NoDoc Str resType := ""
** the value, the default value of '"text"' is used. Set this
** field to "arraybuffer" to access response as Buf.
Str resType := ""

**
** Indicates whether or not cross-site 'Access-Control' requests
Expand Down Expand Up @@ -101,3 +102,4 @@ class HttpReq
**
native Void postFormMultipart(Str:Obj form, |HttpRes res| c)
}

7 changes: 4 additions & 3 deletions src/dom/fan/HttpRes.fan
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ class HttpRes
Str:Str headers := Str:Str[:] { it.caseInsensitive = true }

** The text content of the response when the XMLHttpRequest
** 'responseType' is 'text'.
** `HttpReq.resType` is "text"
Str content := ""

** The binary content of the response when the XMLHttpRequest
** 'responseType' is 'arraybuffer'
** `HttpReq.resType` is "arraybuffer"
Buf contentBuf := Buf(0)
}
}

0 comments on commit 2dd631b

Please sign in to comment.