Filter löschen
Filter löschen

Matlab GZIP http postrequest

7 Ansichten (letzte 30 Tage)
Simon Parten
Simon Parten am 28 Nov. 2018
Beantwortet: Simon Parten am 4 Dez. 2018
Hi Guys,
I want to send a reasonably large matrix (120 * 10000) over http, encoded as JSON.
request =
RequestMessage with properties:
Method: POST
RequestLine: 'POST'
Header: [1×3]
Body: [1×1]
Completed: 0
It's very slow,m in fact, slow enough that the server never actually finishes getting the request. I believe the best way to speed it up, would be to gzip the request body....
Can matlab do this?

Akzeptierte Antwort

Simon Parten
Simon Parten am 4 Dez. 2018
This example of outrageous hackery does appear to do the job. A bit stinky though...
myJson = jsonencode(toSend);
gzipped =;
gzipped.write( uint8(myJson));
closedBytes = outStream.toByteArray();
messageBody.Payload = typecast (closedBytes, 'uint8');
request.Header.addFields(...'Content-Encoding', 'gzip'), ...'application/json'))
response = send(request, uri, opts);
% To decode the stream to check ...
% someStream = messageBody.Payload , 'int8'));
% gzipInStream = someStream );
% inReader =, 'UTF-8');
% aTest = char();
% while data ~=-1
% aTest = [aTest, char(data)];
% data =;
% end

Weitere Antworten (0)


Mehr zu Call Web Services from MATLAB Using HTTP finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by