Network failure” to download PDF from chrome and Edge browser but it is working in IE and firefox

Viewed 768

In my current application, when I click PDF View button, that time PDF is opened in new window and after that we can download the PDF file. During download time it is throwing error for chrome and Edge browser but it is working for IE and Firefox. I searched google I have found similar type of issue fixed using browser content setting. If I applied same, that time PDF View option direct download the pdf file but expected Behavior is first we can view the pdf after that we download the pdf file.

type_parameter = "application/pdf; charset=UTF-8"

header = [("Content-Disposition", "filename=%s" % file_name),('Content-type', 
'application/pdf; charset="UTF-8"')]

Could someone tell how to fixed this issue?

Image1:

enter image description here

Network Failed error:

enter image description here

thanks in advance

Python Code:

content = create_pdf_file()
type= "application/pdf"
h= [("Content-Disposition", "filename=%s" % file_name),('Content-type', 'application/pdf; charset="UTF-8"')]
self._ctx.iLib.forward("display", content, type, h)

display.tmpl:

#def __call__(data, Ctype="application/pdf", h=None)
*##slurp
    #set self.Ctype= Ctype
    #if not h
        #set h= []
    #end if
    #for name, value in h:
        #if name.lower() == 'content-type':
            #set self.Ctype= value
            #silent $headers.remove((name, value))
        #end if
    #end for
    #set self.h= h
    #return data
1 Answers

Change PDF MIME Type in Web Server or Response Headers from

application/pdf
to
application/octet-stream

This problem is when is enabled gzip compression and/or HTTP/2

Enable http/2 for SSL connections is a hugely valuable performance setting. However http2 expects the reported size to match what the webserver reports for streamed content.

Related