Jump to content

MimeType and Meta-tag, what??


albertlee

Recommended Posts

I have learned HTML long time ago,

 

but I feel bad about myself when some one tell me to use MimeType and Meta-tag, which I don't know what they are.

 

Any one use Meta-tag and Mimetype before??

 

just need the experience and I can probably grasp soon

thanks

 

 

Albert

Link to comment
Share on other sites

The mime-type of a file describes what the file is supposed to be. For example a HTML file has mime-type "text/html", and for a PNG image it's "image/png". A webserver will send this mime-type so that the client knows what it's supposed to be receiving. It's got nothing to do with HTML really, and they crop up in a lot of places.

 

Meta tags are just extra information that is given with a HTML document. For example, some meta dags give search engines a list of keywords associated with the site, or tell the browser how often to reload a page. They appear inside the <head></head> tags.

Link to comment
Share on other sites

Yes, it's a protocol, but a very simple one. The client sends a message to the server, something along the lines of: "GET /path/to/htmlfile.html HTTP/1.0". The server then responds with something like:

 

HTTP/1.0 200 OK
Content-type: text/html
Content-length: 1234

<html>
<head>
...
</html>

 

The things at the top of the response are headers, and the "Content-type" header contains the mime-type of that file.

Link to comment
Share on other sites

I'm not familiar with the BitTorrent protocol, so I don't really want to comment on that. GET isn't a UNIX command, it just indicates that the client wants to get a particular file.

Link to comment
Share on other sites

They're not that important, and I'm pretty sure that quite a lot of computing books will talk about them in an offhand manner. Mime-types are just a useful tool for identifying different types of files, nothing more.

Link to comment
Share on other sites

Because it makes sure that the client knows what it's supposed to be receiving. Often the mime-type is worked out by looking at the extension of the file, but some files vary from server to server (for instance, Gentoo's server sends out .xml files as regular HTML instead of XML).

Link to comment
Share on other sites

On apache at least, there's a great big long file associating different file extensions with their appropriate mime-types. Nothing is really contained in the file itself to identify what it is in an easy fashion.

 

Why place such importance on such a trivial issue? As I've stated before, there's nothing particularly complex or interesting with mime-types. They're just another little thing to make programmer's lives easier, really.

Link to comment
Share on other sites

Here is a good example, this very page :). The scripts used on scienceforums.net are written in php and have the .php extension. This is so that when a request is made for said file, the webserver knows that the file needs to be processed/interpreted first by the php interpreter before sending the output to the client/user. However, if you were to just take the .php extension, the web browser wouldn't know what to do with it. Therefore by default the web server is usually set up to send the text/html mimetype (note the Content-Type: Header) so that the browser knows to process the content being sent to it as HTML rather than as image data or xml.

 

You might ask "Well why not just have the browsers always think of .php as HTML files?". This isn't possible as php files/script are simply programs/scripts that process data and output data. It might not always be in the form of a html document, it could be image data (using PHP's GD libraries) or xml data or simply text. In these cases the php script can often override the default Content-Type and send a different Mime-type using the header() functionality. If in these cases the data were to be processed as text/html data, the way in which the data would be displayed would be wrong (for instance the image data would just be gibberish).

 

 

Request

GET /forums/showthread.php?t=12388 HTTP/1.1

Host: http://www.scienceforums.net

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

Accept-Language: en-us,en;q=0.5

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 300

Connection: keep-alive

Referer: http://www.scienceforums.net/forums/forumdisplay.php?f=54

Cache-Control: max-age=0

Response (Minus Content(HTML))

HTTP/1.x 200 OK

Date: Sun, 26 Jun 2005 10:40:34 GMT

Server: Apache/1.3.33 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.11 FrontPage/5.0.2.2635 mod_ssl/2.8.22 OpenSSL/0.9.7e

X-Powered-By: PHP/4.3.11

Expires: 0

Cache-Control: private, post-check=0, pre-check=0, max-age=0

Pragma: no-cache

Set-Cookie: SFNthread_lastview=45aa7a4f78e391b2b12fd647d484303fax3x-ix12396ysx10x%221119781450%22yix12349ysx10x%221119729407%22yix12388ysx10x%221119782176%22y_; path=/

Content-Length: 107453

Content-Type: text/html; charset=ISO-8859-1

Age: 22

Via: HTTP/1.1 ntl_site (Traffic-Server/5.2.4-59306 [c sSf ])

Link to comment
Share on other sites

You download the output from the php script having been parsed by the php interpreter.

 

If the webserver isnt set up correctly (ie setting up .php extensioned files so that they are interpreted with the php interpreter (usually involves AddType etc in Apache)), then the php file (actual code contents) is sent when you request the file. But normally when you make a request for the file to the webserver, the webserver knows not to simply send the contents (as it has been configured with .php scripts in mind) and so the file is parsed through the php interpreter and the output of that send by the webserver to your PC. If the webserver is setup properly you cannot just 'download' the php file with its code contents, as the webserver will always allow it to be parsed/interpreted by the php interpreter first.

 

Not sure if thats what you mean but..........

Link to comment
Share on other sites

albertlee, some links that might interest you and shed some light on the topic (although it will probably mean you want to do further reading into the subject via google etc) are -

 

http://en.wikipedia.org/wiki/HTTP

http://www.jmarshall.com/easy/http/

 

The second one goes a little more in depth and is a bit more interesting, but the first might have a few more links that can be followed and investigated further.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.