You are not logged in.
Pages: 1
I am attempting to correctly set the content-type when sending parts of binary files using code like this:
AddToCSV('Accept-Ranges: bytes', Ctxt.Call.OutHead, #13#10);
AddToCSV('Content-Range: bytes '+ inttostr(RangeStart) +'-'+inttostr(RangeEnd)+'/'+inttostr(SrcFileSize), Ctxt.Call.OutHead, #13#10);
AddToCSV(GetMimeContentTypeHeader('',SrcFileName), Ctxt.Call.OutHead, #13#10);
Ctxt.ReturnBlob(blob, HTTP_PARTIALCONTENT);
In the procedure, the content-type is correctly set as video/H264 in the Ctxt.Call.OutHead, but when the header reaches the client, it is content-type: application/json; charset=UTF-8
Any suggestions where this might be overridden? I have tried stepping through ReturnBlob, but when it returns to my proc, the header still looks correct, so I am not sure where it is happening.
Using v1.18
Offline
ReturnBlob() should already set the content type for you, from the blob binary content.
Yo have a FileName optional parameter to specify the source file name if needed:
Ctxt.ReturnBlob(blob, HTTP_PARTIALCONTENT, true, SrcFileName);
Offline
It looks as if it always thinks the binary data is json, so maybe that is used as a fallback when it can't determine the data type? Since these are partial files, not full files (which would be too big - up to 1 gb), I assume determining the content type will not succeed. How can I provide / override / force the content type when serving binary data?
Providing the full path of the original file does not resolve the issue - is still sends the content-type as json.
Offline
TSQLRestServerFullMemory
Offline
> How can I provide / override / force the content type when serving binary data?
Try with base Ctxt.Returns where you have full control, for example:
Returns(ResultVar.AsJSON, HTTP_SUCCESS, 'video/H264, True, True);
Last edited by igors233 (2022-04-09 04:52:13)
Offline
Pages: 1