fixed blob loading

This commit is contained in:
Luxferre
2023-03-25 18:52:38 +02:00
parent 35bee36cb9
commit b7e9b40e32
3 changed files with 32 additions and 35 deletions
+11 -6
View File
@@ -6,19 +6,24 @@
// input is optional and only considered for resource type 7
function gopherRequest(resource, input, successCb, errorCb) {
var xsock = navigator.mozTCPSocket.open(resource[2], (resource[3]||70) | 0, {binaryType: 'string'}),
type = resource[0][0], databuf = ''
xsock.ondata = function(data) {
databuf += data.data
var xsock = navigator.mozTCPSocket.open(resource[2], (resource[3]||70) | 0, {binaryType: 'arraybuffer'}),
type = resource[0][0], databuf = []
xsock.ondata = function(e) {
var i = 0, db = new Uint8Array(e.data), l = db.length
for(;i<l;i++)
databuf.push(db[i])
}
xsock.onclose = function() {
successCb(databuf, type)
var res = new Uint8Array(databuf)
successCb(res, type)
databuf = []
}
xsock.onerror = errorCb
xsock.onopen = function() {
var selpath = resource[1]
if(type == '7' && input)
selpath += '\t' + input
xsock.send(selpath + '\r\n') // send CRLF-terminated selector path and optionally the search string
var reqbuf = (new TextEncoder).encode(selpath + '\r\n').buffer
xsock.send(reqbuf) // send CRLF-terminated selector path and optionally the search string
}
}