NexusDB Newsgroups

NexusDB Newsgroups (
- (
-   -   Server delivering binary content (

RichardLight 26th February 2020 10:19 PM

Server delivering binary content
We're looking to replace a set of CGI programs with equivalent .nxscript applications. One of these programs is an 'image server', which delivers a dynamically sized version of an image file.

The NexusDb web server component (at least the version we are working with - 4.5003) is currently designed only to deliver a textual response. I have managed to hack it to the point where it will deliver images, but the result isn't pretty.

Essentially I have added a socStream property to the nxllSimpleOutputCache, and changed the SaveToFile procedure so that it outputs this stream if it is instantiated, rather than outputting any text that might have been pushed to the output cache. I also needed to specify the response content type. I can set this in the script:

Server.SetVar('response-content-type', 'image/jpeg');

but I also needed to add code so that this setting is respected, and not overwritten in the ProcessRequest procedure:

if (GetVar('response-content-type') <> '') then
fReplyHeaders.Add('Content-type: '+GetVar('response-content-type'))
fReplyHeaders.Add('Content-type: '+ctype+'; charset=UTF-8');

However, if you're returning a binary response, the content type ought to reflect this without needing to be specified in your script.

Before I proceed to make larger-scale changes to the code, I thought I would check in with this group. Has anyone else attempted this, or am I on my own?



All times are GMT +11. The time now is 10:56 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.