Build Your Own Arcade Controls Forum

Main => Software Forum => Topic started by: Howard_Casto on January 21, 2014, 05:01:48 am

Title: Not sure if this should be posted here. List of Content-type: definitions?
Post by: Howard_Casto on January 21, 2014, 05:01:48 am
A couple of my projects have made me realize that it might just be simpler to byte the bullet and make a webserver from scratch. 

A slight snag I've been having are the "Content-type:" definitions you need to supply when sending along a file.  There are various lists out there, but most are either incomplete or aren't very copy/paste friendly. 

Any of you guys have a good list or a link to a good one?
Title: Re: Not sure if this should be posted here. List of Content-type: definitions?
Post by: spoot on January 21, 2014, 10:31:18 am
I've run LAMP for years with downloads and have never worried about content-type that I can recall.  What specific snag are you hitting?
Title: Re: Not sure if this should be posted here. List of Content-type: definitions?
Post by: Howard_Casto on January 21, 2014, 10:37:05 am
Not a snag per say... it's just that android, particularly the older versions, seems to be quite picky.  It'll try to download and save things as a file that should normally be displayed in browser.  It seems to be an android exclusive problem, but I'll bet other non-standard browsers are going to have issues as well.  I've got all of the common ones hooked up, but I'd like to just be done with it and lookup from a list. 
Title: Re: Not sure if this should be posted here. List of Content-type: definitions?
Post by: spoot on January 21, 2014, 12:01:56 pm
Ah, have not pissed around with Android at all.  Bought a book to help program a game on one.......then saw game already existed..........haven't looked back.   :P
Title: Re: Not sure if this should be posted here. List of Content-type: definitions?
Post by: twistedsymphony on February 05, 2014, 09:38:44 am
Not a snag per say... it's just that android, particularly the older versions, seems to be quite picky.  It'll try to download and save things as a file that should normally be displayed in browser.  It seems to be an android exclusive problem, but I'll bet other non-standard browsers are going to have issues as well.  I've got all of the common ones hooked up, but I'd like to just be done with it and lookup from a list. 

I'm not sure if you ever got this working but you'll want to leave content-type as it is. to force download you'll need to set "Content-Disposition: attachment;" in the header...

alternatively you can force set this for certain file types in the apache config:
Code: [Select]
<FilesMatch "\.(?i:doc|odf|pdf|rtf|txt)$">
  Header set Content-Disposition attachment
</FilesMatch>


This is the proper way to do this, but sometimes the browser still ignores it.
Title: Re: Not sure if this should be posted here. List of Content-type: definitions?
Post by: liquid8 on February 05, 2014, 09:56:13 pm
You want this:
http://en.wikipedia.org/wiki/Internet_media_type (http://en.wikipedia.org/wiki/Internet_media_type)

What the heck projects are making you need to create a web server? :)

edit: forgot to mention.. in Android it is on an app to say whether or not they handle certain MIME types.. particularly older Android web browsers didn't handle all of them - so you will run into that issue. If anyone is using an older version of Android, they should probably not be using the stock web browser.