Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Problems rendering an image + jpeg images not working

From: brett:codeconscious at: 31-Aug-2002 11:10

> Earlier, I looked at documentation about this "problem," and it was not to > be a particular problem with earlier versions of Apache. On a lark, I > decided to try the proposed fixes, which meant doing two things. Change
> name of the script to begin with "nph-" meaning non-parsed-headers (or
Didn't know about nph - fancy a silly little prefix having such a large impact :^) What I did find out though in the docs for Apache 1.3 (which I'm using) is that the output from CGI is unbuffered anyway. So I gave up with Apache and created a little dedicated REBOL websever based on webserver.r. This little script ignores the request and just outputs three images in sequence just like the CGI was doing. Edit the HTML and make the SRC of IMG to point to http://localhost:8000/ and run the script below in CORE 2.3 (I didn't know how to update it to latest core with the changes to networking - another thing on my learing to do list). What you get in Netscape is a sequence of three images yippee! 1) It would be nice to know how to update this script to the latest Core. 2) This little script proves to me that the content is right for the CGI but not the iteraction between REBOL and Apache for unbuffered output. A mystery. Regards, Brett. REBOL [ Title: "Serve Stream" Date: 10-June-2000 File: %serve-stream.r Purpose: { built on webserver.r to test streaming images. } ] images: [ #{ 47494638396125002500B30000FFFFFF0000008A8A8A454545111111EFEFEF55 55559A9A9AAAAAAABBBBBB666666DFDFDF212121CFCFCF31313176767621F904 00000000002C000000002500250000048B10C849ABBD38EBCDBBFF5C21086089 104190945D61A4A9C16E0D03A7C39C1DE81DE43ACBC30753042D30870F71AC04 1808C18DD1BC2C7C87AA45712314B494868F049E0CBADF3220E133AA01AFDBE2 7DBD01D5DC1BF3DD4B51DF07636F703E737C37326F6C37596F5237696A713883 006730646F97292B83083799803DA16F22029D95A9AAABACADAE0011003B } #{ 47494638396125002500B30000FFFFFF0000008A8A8A454545111111EFEFEF9A 9A9A555555CFCFCFBBBBBB767676212121AAAAAADFDFDF31313166666621F904 00000000002C00000000250025000004CD10C849ABBD38EBCDBBFF60E8218670 0CE8538856611C4420CFF2C34E8512D37C40DC8082A3470C246E8A6260A038CC 04ACC28EF660501632A8C84023085614C693E5940D1A16C4D4C09A061C07C4C4 E0468B88D04679666BFB0E02090505023D0E604073583C8789130903442A8E41 493D045694088B3C0A88895C3D0B479400A13C5AA5A7330372A500093C5EAF12 059C4B768F02286C228532B3B0060A9134A920C50127434A9921C94A330B48D1 5DAE2208D5320BD72CD0B207BD8E0C02E5E50609B9B4EBECEDEEEFF0EB11003B } #{ 47494638396125002500B30000FFFFFF0000008A8A8A454545111111CFCFCF55 5555666666BBBBBB2121219A9A9AEFEFEFDFDFDF313131AAAAAA76767621F904 00000000002C00000000250025000004CF10C849ABBD38EBCDBBFF60D82D8822 9CA7C388167224412CCF43C102C530EF3B618705026F2833880EC3C600F59211 443AD9008131C844D6D901D3B8020760F0B6B2C8068C374CE1219451D31386A3 B953A40B8AC7A0CD33FC440E7C3C04060A0B70303B09070A7F7008440906022B 70000244330F96980D9327077B349619085D318EA4140E3202AA1766AE210C6F 18653376200FA8170B028204871F980104B5000C0A483CB21F8209609901631F 90D23CD41F0CD733040E37C4D20902C2372EA7329E02A9AFEDEEEFF0F1F2F211 003B } ] listen-port: open/direct/lines tcp://:8000 ; port used for web connections errors: [ 400 "Forbidden" "No permission to access:" 404 "Not Found" "File was not found:" ] send-error: function [err-num file] [err] [ err: find errors err-num insert http-port join "HTTP/1.0 " [ err-num " " err/2 "^/Content-type: text/html^/^/" <HTML> <TITLE> err/2 </TITLE> "<BODY><H1>SERVER-ERROR</H1><P>REBOL Webserver Error:" err/3 " " file newline <P> </BODY> </HTML> ] ] emit: func [data] [ if block? data [data: rejoin data] write-io http-port data length? data write-io http-port CRLF 2 ] boundary-string: "ThisRandomString" boundary: rejoin [CRLF {--} boundary-string] buffer: make string! 1024 ; will auto-expand if needed forever [ http-port: first wait listen-port clear buffer while [not empty? request: first http-port] [ repend buffer [request newline] ] repend buffer ["Address: " http-port/host newline] print mold buffer mime: "text/plain" emit [system/options/cgi/server-protocol { 200 OK}] emit [{Server: } system/options/cgi/server-software] emit [ {Content-Type: multipart/x-mixed-replace;} { boundary-string="} boundary-string {"} ] emit {} emit boundary repeat i 3 [ emit {Content-Type: text/gif} emit {} emit pick images i emit boundary wait 00:00:02 ] emit {Done.} close http-port ]