Streaming pdf with URLLib

S

Scooter

I'm playing around with urllib, and httplib, trying to make something
of a pdf proxy.I have a pdf that lives on an internal web server, and
I would like to be able to stream it to my external server. (this is
just a test for a bigger process. Yes I could just copy the pdf to the
external box). I was playing with URLLib doing something like

#!/usr/bin/python

import urllib

u = urllib.urlopen('https://myinternal.server/pdfs/pdfstreamer.aspx')
print 'Content-type: application/pdf\n\n'
# print 'Content-type: application/x-msdownload; name=\"FileName\"\n
\n'
# print 'Content-Dispostion: attachment; filename=\"FileName\"\r\n\n'

pdfdoc = u.read()
print pdfdoc

Hitting my pdfstreamer.aspx app directly through a browser renders a
pdf just fine. So now I'm attempting to use this python app on an
external webserver, access it as a cgi, to pull the pdf, and then re-
render it, but at that point it just shows me the raw pdf in
the browser.
 
A

Aahz

#!/usr/bin/python

import urllib

u = urllib.urlopen('https://myinternal.server/pdfs/pdfstreamer.aspx')
print 'Content-type: application/pdf\n\n'
# print 'Content-type: application/x-msdownload; name=\"FileName\"\n
\n'
# print 'Content-Dispostion: attachment; filename=\"FileName\"\r\n\n'

pdfdoc = u.read()
print pdfdoc

Hitting my pdfstreamer.aspx app directly through a browser renders a
pdf just fine. So now I'm attempting to use this python app on an
external webserver, access it as a cgi, to pull the pdf, and then re-
render it, but at that point it just shows me the raw pdf in
the browser.

What application type does the browser report?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top