"put binary" command is just outputting text instead of a binary file on LiveCode Server -


i'm using livecode community server 8.1.2 on windows server 2016 datacenter (running apache 2.4)

i use following code

put header "content-disposition: attachment; filename=" & tfilename put header "content-type: application/pdf" put header "content-transfer-encoding: binary" put url("binfile:" & "../resources/documents/" & tactualfilename tbinarydata put binary tbinarydata 

when included in script called browser code returns data text in browser window rather pdf file can downloaded.

a few months ago wrote code , worked, returned today , doesn't.

i've double checked , i'm sure it's correct have no idea else have broken it.

i've tested on chrome 59 on windows 8.1 pro chrome 59 on macos sierra 10.12.5 safari on ios 10.3.2

any or guidance welcome.

edit: network headers chrome shown below network headers chrome

edit: amended code remove word "binary" line 4 - generating error producing text output @ end of returned result - hasn't resolved problem - still getting text returned , "content-type:text/html" in response header

edit: there 2 blank lines @ beginning of source (after using view source, ctrl-u on chrome)

view source

after couple of days of working on have solution. it's work around , don't know actual problem completeness it's worth posting.

the 2 blank lines before "%pdf" code problem , after adding various debugging 'put' statements tracked offending code down the following 2 statements

require ("codesnippets.lc") require ("databaseoperations.lc") 

each of these statements added line output. presumed referenced files must somehow outputting blank line goes unnoticed normal html page.

there's no code in them test added following code last line of 'codesnippets.lc'

put "test1" 

and added similar line between require statements

require ("codesnippets.lc") put "test2" require ("databaseoperations.lc") 

the output showed "test1" , "test2" on different lines. can't explain what's happening between last line of required script , next line of main script. if can shed light on i'd grateful.

it's worth noting have other require statements didn't show issue. following worked without producing line

require ("../config.lc") require("../resources/library/templatefunctions.lc") 

as work around moved copies of various bits of code need document download new file called "documenthandler.lc" , called following

require("../resources/library/documenthandler.lc") 

it works now.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -