content type headers

2009-07-02 Thread Dermot Paikkos
Hi, 

I've got some old code to deal with and I have hit a problem. 

If there is a request for a page that has mixed content EG: 'text/html' 
and 'image/jpeg', the image media is not being displayed correctly under 
the FireFox browser. 

The way things currently work is that media other than text/html is 
output from a separate page, so you might have a bit of html that for an 
image that looks like this:



Within showImage.html you have a 1) a piece of code that supposedly sets 
the content_type to image/jpeg, and 2) calls to a function that 
literally prints the image based on is CGI param 'imageid'.

In my experiments, IE is correctly identifying the media and Firefox is 
not. However I think FF is expecting the content_type to be sent with 
the media and IE is guess* based upon the media it receives.

So my question, initially, is can a request set the content_type more 
than once?

Thanx,
Dp.



--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: content type headers

2009-07-02 Thread Gunnar Hjalmarsson

Dermot Paikkos wrote:
If there is a request for a page that has mixed content EG: 'text/html' 
and 'image/jpeg', the image media is not being displayed correctly under 
the FireFox browser.


What exactly do you mean by that? When you use a browser to request a 
usual HTML page with IMG elements, there are multiple subsequent 
request/response pairs, one for each image. Could you post the source 
code of a page that behaves as you say?


The way things currently work is that media other than text/html is 
output from a separate page, so you might have a bit of html that for an 
image that looks like this:




Within showImage.html you have a 1) a piece of code that supposedly sets 
the content_type to image/jpeg, and 2) calls to a function that 
literally prints the image based on is CGI param 'imageid'.


As long as the images are accessible from the web, I do not see why you 
would need to use a separate script like that.


In my experiments, IE is correctly identifying the media and Firefox is 
not. However I think FF is expecting the content_type to be sent with 
the media and IE is guess* based upon the media it receives.


What if you simply try to view an image with FF directly?

http://www.example.com/images/someimage.jpg

If that's not displayed as expected, there may be something with the 
configuration of your FF browser.


--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




RE: content type headers

2009-07-02 Thread Hellman, Matthew
>>Hi,
>>
>>I've got some old code to deal with and I have hit a problem.
>>
>>If there is a request for a page that has mixed content EG: 'text/html'
>>and 'image/jpeg', the image media is not being displayed correctly under
>>the FireFox browser.
>>
>>The way things currently work is that media other than text/html is
>>output from a separate page, so you might have a bit of html that for an
>>image that looks like this:
>>
>>
>>
>>Within showImage.html you have a 1) a piece of code that supposedly sets
>>the content_type to image/jpeg, and 2) calls to a function that
>>literally prints the image based on is CGI param 'imageid'.

This sounds fine, but it obviously isn't working right?  For some examples, 
see: http://www.perlmonks.org/?node_id=18565

>>In my experiments, IE is correctly identifying the media and Firefox is
>>not. However I think FF is expecting the content_type to be sent with
>>the media and IE is guess* based upon the media it receives.

I believe this is correct.  Regardless of the content-type header value, IE 
will take an educated guess. FF will not. This would jive with the behavior I 
would expect with an incorrect content-type header.

>>So my question, initially, is can a request set the content_type more
>>than once?

Sure, you can add 10 different content type headers if you want, each with 
different values.  I have no idea what a given browser will do though;-)  The 
answer to your problem seems to be making sure one and only one content-type 
header is returned with the image, and that it has the correct value (e.g. 
Content-Type: image/jpeg or whatever). It would help if you could use something 
like the FF liveHttpHeaders add-on and show us the actual HTTP headers in the 
response for the request "/images/showImage.html?imageid=123456".


-Message Disclaimer-

This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to conn...@principal.com and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.

Nothing in this message is intended to constitute an Electronic signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.

While this communication may be used to promote or market a transaction
or an idea that is discussed in the publication, it is intended to provide
general information about the subject matter covered and is provided with
the understanding that The Principal is not rendering legal, accounting,
or tax advice. It is not a marketed opinion and may not be used to avoid
penalties under the Internal Revenue Code. You should consult with
appropriate counsel or other advisors on all matters pertaining to legal,
tax, or accounting obligations and requirements.


--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: content type headers

2009-07-02 Thread Gunnar Hjalmarsson

Hellman, Matthew wrote:
The answer to your problem seems to be making sure one and only one 
content-type header is returned with the image, and that it has the 
correct value (e.g. Content-Type: image/jpeg or whatever).


Right, and it just struck me that this is probably a web server 
configuration issue. A sensibly configured server should send the 
correct content-type header out from the file extension.


Please see the attached file, which is the config file for this purpose 
on my own (Apache) server. There you can see that a jpg extension 
results in content-type image/jpeg, a png extension gives image/png etc.


--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
# This is a comment. I love comments.

# This file controls what Internet media types are sent to the client for
# given file extension(s).  Sending the correct media type to the client
# is important so they know how to handle the content of the file.
# Extra types can either be added here or by using an AddType directive
# in your config files. For more information about Internet media types,
# please read RFC 2045, 2046, 2047, 2048, and 2077.  The Internet media type
# registry is at .

# MIME type Extension
application/EDI-Consent
application/EDI-X12
application/EDIFACT
application/activemessage
application/andrew-insetez
application/applefile
application/atomicmail
application/batch-SMTP
application/beep+xml
application/cals-1840
application/commonground
application/cybercash
application/dca-rft
application/dec-dx
application/dvcs
application/eshop
application/http
application/hyperstudio
application/iges
application/index
application/index.cmd
application/index.obj
application/index.response
application/index.vnd
application/iotp
application/ipp
application/isup
application/font-tdpfr
application/mac-binhex40hqx
application/mac-compactpro  cpt
application/macwriteii
application/marc
application/mathematica
application/mathematica-old
application/msword  doc
application/news-message-id
application/news-transmission
application/ocsp-request
application/ocsp-response
application/octet-streambin dms lha lzh exe class so dll
application/oda oda
application/ogg ogg
application/parityfec
application/pdf pdf
application/pgp-encrypted
application/pgp-keys
application/pgp-signature
application/pkcs10
application/pkcs7-mime
application/pkcs7-signature
application/pkix-cert
application/pkix-crl
application/pkixcmp
application/postscript  ai eps ps
application/prs.alvestrand.titrax-sheet
application/prs.cww
application/prs.nprend
application/qsig
application/remote-printing
application/riscos
application/rtf rtf
application/sdp
application/set-payment
application/set-payment-initiation
application/set-registration
application/set-registration-initiation
application/sgml
application/sgml-open-catalog
application/sieve
application/slate
application/smilsmi smil
application/timestamp-query
application/timestamp-reply
application/vemmi
application/vnd.3M.Post-it-Notes
application/vnd.FloGraphIt
application/vnd.accpac.simply.aso
application/vnd.accpac.simply.imp
application/vnd.acucobol
application/vnd.aether.imp
application/vnd.anser-web-certificate-issue-initiation
application/vnd.anser-web-funds-transfer-initiation
application/vnd.audiograph
application/vnd.businessobjects
application/vnd.bmi
application/vnd.canon-cpdl
application/vnd.canon-lips
application/vnd.claymore
application/vnd.commerce-battelle
application/vnd.commonspace
application/vnd.comsocaller
application/vnd.contact.cmsg
application/vnd.cosmocaller
application/vnd.cups-postscript
application/vnd.cups-raster
application/vnd.cups-raw
application/vnd.ctc-posml
application/vnd.cybank
application/vnd.dna
application/vnd.dpgraph
application/vnd.dxr
application/vnd.ecdis-update
application/vnd.ecowin.chart
application/vnd.ecowin.filerequest
application/vnd.ecowin.fileupdate
application/vnd.ecowin.series
application/vnd.ecowin.seriesrequest
application/vnd.ecowin.seriesupdate
application/vnd.enliven
application/vnd.epson.esf
application/vnd.epson.msf
application/vnd.epson.quickanime
application/vnd.epson.salt
application/vnd.epson.ssf
application/vnd.ericsson.quickcall
application/vnd.eudora.data
application/vnd.fdf
application/vnd.ffsns
application/vnd.framemaker
application/vnd.fsc.weblaunch
application/vnd.fujitsu.oasys
application/vnd.fujitsu.oasys2
application/vnd.fujitsu.oasys3
application/vnd.fujitsu.oasysgp
application/vnd.fujitsu.oasysprs
application/vnd.fujixerox.ddd
application/vnd.fujixerox.docuworks
application/vnd.fujixerox.docuworks.binder
application/vnd.fut-misnet
application/vnd.grafeq
application/vnd.groove-account
application/vnd.groove-identity-message
application/vnd.groove-injector
application/vnd.groove-tool-message
application/vnd.groove-tool-template
appli

RE: content type headers

2009-07-02 Thread Hellman, Matthew
I don't think that's it's a web server thing, because he's dynamically 
generating the images and not using a .jpg extension. Doing it this way allows 
you do such things as resize the image on the fly using URL parameters. 
Something like:

src="/images/showImage.html?imageid=123456&size=800x600

the HTTP response headers would probably shed the most light on the problem, 
nudge, nudge;-)

>>-Original Message-
>>From: Gunnar Hjalmarsson [mailto:nore...@gunnar.cc]
>>Sent: Thursday, July 02, 2009 1:24 PM
>>To: beginners-cgi@perl.org
>>Subject: Re: content type headers
>>
>>Hellman, Matthew wrote:
>>> The answer to your problem seems to be making sure one and only one
>>> content-type header is returned with the image, and that it has the
>>> correct value (e.g. Content-Type: image/jpeg or whatever).
>>
>>Right, and it just struck me that this is probably a web server
>>configuration issue. A sensibly configured server should send the
>>correct content-type header out from the file extension.
>>
>>Please see the attached file, which is the config file for this purpose
>>on my own (Apache) server. There you can see that a jpg extension
>>results in content-type image/jpeg, a png extension gives image/png etc.
>>
>>--
>>Gunnar Hjalmarsson
>>Email: http://www.gunnar.cc/cgi-bin/contact.pl


-Message Disclaimer-

This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to conn...@principal.com and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.

Nothing in this message is intended to constitute an Electronic signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.

While this communication may be used to promote or market a transaction
or an idea that is discussed in the publication, it is intended to provide
general information about the subject matter covered and is provided with
the understanding that The Principal is not rendering legal, accounting,
or tax advice. It is not a marketed opinion and may not be used to avoid
penalties under the Internal Revenue Code. You should consult with
appropriate counsel or other advisors on all matters pertaining to legal,
tax, or accounting obligations and requirements.


--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/