Is it possible to receive byte and string data simultaneously in an HTTP response? A cannot mix the two put in a json but you get the idea:
private async getFile(): Promise<{ data: Blob, checksum: string }> {
return this.http.get('some url/getfile...', {
'headers': accessToken
}).pipe(timeout(10000)).toPromise().then(res => {
if (res['status'] === 200 && res['body']) {
return {
data: res['body']['data'],
checksum: res['body']['checksum']
};
}
return undefined;
}).catch(() => undefined);
}
What's the proper way?
My ideas:
Should the server maybe put the checksum into the response header?
Or, should it send also the checksum as bytes? If so, how to separate it from the actual data?
Or what if I'd combine the two in a single byte stream and if e.g. md5 was used to produce the checksum I would know that the first (or last) 128 bits (= 16 bytes?) are the checksum, the rest is the actual data.
What I don't want is to (1) do it with separate requests (2) put the checksum in some text file on the server side and zip it with the actual file, then unzip the archive on the client side.