#1  
Old 26th February 2020, 11:19 PM
RichardLight RichardLight is offline
Member
 
Join Date: Nov 2011
Posts: 54
Default 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'))
else
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?

Thanks,

Richard


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Nxscript server delivering binary content RichardLight nexusdb.public.support 3 6th March 2021 07:51 PM
Content Locks and Transactions work sri.ajay nexusdb.public.support 12 27th November 2015 08:32 PM
New user...How to view content of nx1 files? gorlaz nexusdb.public.support 11 15th March 2011 08:12 PM
Source Server smaller that Current Binary Release Chris nexusdb.public.support 2 9th January 2006 07:28 PM
Binary Server Bernhard Roos nexusdb.public.support 4 3rd December 2005 11:08 AM


All times are GMT +11. The time now is 03:18 PM.


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