fixed blob loading
This commit is contained in:
+11
-6
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user