Those software developers, who are creating the best codes, are the most successful person. However, if we are looking at the perfect world, success depends on how one can work with people to get their job done. From purchasing refrigerator from Amazon.com to chat with buddies in a Facebook, everything can accomplish through HTTP that managed by software developer.
HTTP is a protocol behind the WWW. enables a web server from a datacenter to transfer information to personal computers, where people can read web page, describing essential information. In this post, we are going to see at the attitudes of software development and grab the understanding of HTTP that helps you in writing better web applications and services.
The HTTP address is one of the most essential parts of the web. When I want to search a dish featuring Chicken, I might open my web browser and simply enter website name, i.e. http://allrecipes.com in the address bar. So, I can reach at that site to search Chicken recipe. This syntax is understood by my web browser and knows it requires for creating an HTTP request to a server named http://allrecipes.com/.
Later, we are going to talk about the meaning of “make an HTTP request” and all the networking details included. As of now, we are going to focus on http://allrecipes.com/.
The referring address, i.e. http://allrecipes.com/ is known as URL that abbreviated as a uniform resource locator. A specific resource is represented by URL on the web. In this case, http://allrecipes.com is the resource. Resources are things like images, pages, files, and videos through which one can interact with on the web.
Furthermore, one can also find different URLs inside the same website, i.e. http://allrecipes.com/Recipe/Restaurant-Style-Buffalo-Chicken-Wings/ for Restaurant-Style Buffalo Chicken Wings and http://allrecipes.com/Recipe/Buffalo-Chicken-Dip/ for Buffalo Chicken Dip.
Now, let’s break this URL into three parts:
1. http, is the part before the ://, which is better known as the URL scheme. With this, we can describe access a particular resource and in such case, it notifies the browser to use the HTTP protocol. Moving towards different scheme-https, users might run into other schemes such as mailto for email addresses and ftp for the File Transfer Protocol. After the :// everything will be particular to a specific scheme. Thus, a legal http URL may not be a legal mailto URL.
2. Allrecipes.com is the host and it tells which computer on the internet is hosting the resource. The Domain Name System (DNS) is used by the computer for translating allrecipes.com into a network address and after that, it will know where to send a request. It will also specify the host portion by using an IP address.
3. /Recipe/Restaurant-Style-Buffalo-Chicken-Wings/ is the URL path and the allrecipes.com should recognize particular resource that requested by this path and respond properly.
Many a time, a real resource will be pointed by a URL on the host’s file system or hard drive. Such as, the http://images.media-allrecipes.com/userphotos/140×140/00/70/88/708833.jpg might point to a jpg image file that adds on the allrecipes.com server. But, there are some resources to be dynamic. The URL http://allrecipes.com/Recipe/Chicken doesn’t available to a real file on the server. Instead, some apps are running on the allrecipes host that will obtain that request and create a resource by using content from a database.
This application might be created by using PHP, Perl, Ruby on Rails, ASP.NET, or other web technology that respond to incoming requests by sending HTML for a browser to display. It is fact that many websites are trying to avoid to add real name in their URL. Usually, file name is connected with particular technology such as .aspx for Microsoft’s ASP.NET technology; however, many URL will outlast the technology that utilized for hosting and serving them.
Secondly, there are many sites that put keywords into a URL to make it optimize for search engine that will rank the resource higher in search engine results. These days, descriptive keywords are important for URLs rather than file names.
Query Strings, Fragments, and Ports
In this section, we are going to study regarding URL schemes, hosts, and paths. Let’s begin with URL with a port number:
The port number the host is represented by the number 80 to listen for HTTP requests. Port 80 is a default number for http and thus, it is generally excluded from a URL. If the server is listening on a port other than port 80, then you have to require a port number that usually seen in testing, debugging, or development environments.
Everything after Question Mark (?) is called the query. The query also known as the query string that contain information for the destination website to utilize or interpret. One shouldn’t find formal standard for how the query seems to be as it depends on the application to interpret the values it finds. However, you will see the majority of query strings that used to pass name/value pairs in the form name1=value1 & name2=value2.
For example: http://foo.com?first=Chicken&last=Recipe includes two name value pairs. The first pair has the name first and the value Chicken while the second pair is the name last with the value Recipe. If we are looking at the earlier URL http://www.bing.com/search?q=chicken, the search engine will see the “q” connected with the value “chicken“.
It seems that Bing search engine is searching for the value “q” as the search term. We can imagine of the URL as it is resource that represents the Bing search results for Chicken. Lastly, one more URL: http://server.com?recipe=chicken#ingredients.
The part in URL after the # sign is better known as the fragment, which is different than the other pieces that we have looked at so far as the fragment is not processed by the server like the URL path and query string. The fragment is utilized only for clients and particular section of a resource is recognized by it.
Purposely, we can use the fragment to recognize specific HTML element in a page by the element’s ID. Moreover, the initial display of a web page will be supported by web browsers like the fragment recognizes the top of the element of the screen. For example: http://blogs.perceptionsystem.com/12-attitudes-newbie-learn-experienced-software-developer/#attitudes-08
Your web browser should scroll down the page in order to display the attitude-08 section of a particular blog post on my blog, if you are following the URL. No doubt, the entire resource is retrieved by browser, but it focused your attention to particular area- as the attitude-08 section. Moreover, you can also suppose the HTML for the blog post that seems like
Ensure to have the element with an ID of attitude-08 available at the top. Putting everything together, we have learned enough. We also known a URL are broken into the below given pieces: b
Get more idea by my professional Perception System’s blog capture
The software developers, who are working with the web, make themselves aware of the character encoding issues with URLs. The URLs that described in the official documents are too lengths to make URLs as usable and interoperable.
URL should be easy to communication via email as it is print on a bumper sticker. Having the space character is not as safe as it can mistakenly appear or disappear at the time of a URL is in printed form. “#” and “^” are other unsafe characters that shouldn’t add in the URL. Other than this, RFC 3986 also considered as the safe characters for URLs as it is an alphanumeric characters in US-ASCII
and also have some special characters like (“:” and “/”).
Luckily, you can able to transmit unsafe characters in a URL, but the unsafe characters should be % encoded whereas %20 is the encoding for a space character. For example: you have to create the URL for named “^my resume.txt” on someserver.com. The legal encoded URL seems like: http://someserver.com/%5Emy%20resume.txt
You will find “^” and space characters in percent encoded. There are many web application frameworks providing an API for easy URL encoding. You have to run URLs that dynamically created through an encoding API on the server side.
Resources and Media Types
In this post, we have focused on URLs and trying to simplify everything. But, what it means when we enter a URL into the browser? It simply means that we want to see or retrieve some resources. There are many things to see on the web and later, we will also look at how HTTP also enables us to create, delete, and update resources. For now, we have to focus on recovery.
Here, we are not been very particular for the types of resources we desire to recover as there are many Web resource types like hypertext documents, XML documents, images, video, audio, executable applications, and Microsoft Word documents. The included parties have to be particular and precise for the type of the resource if they want serve a resource or display a resource properly.
While the host responds to an HTTP request, it returns a resource and specifies the type of the content. HTTP relies on the Multipurpose Internet Mail Extensions (MIME) standards in order to particular content types. MIME standards are used by HTTP for the same purpose though MIME was originally designed for email communications.
A Quick Note On File Extensions
Some of you might be thinking that a browser would rely on the file extension in order to decide the content type of an incoming resource. So, if the browser requests “frog.jpg”, it should be treated as a JPG file, and treat “frog.gif” as a GIF file.
But, for most of the browsers the file extension is the final destination that will decide the actual content type. Talking about the file extensions, it can be misleading as we are requested a JPG file doesn’t signify the server has to react with data that encoded into JPG format. As the first looking at the content type, Microsoft documents Internet Explorer tag specified by the host. The first 200 bytes of the response will be scanned by the IE, if you are not providing a content type.
Lastly, IE will fall back on the file extension, if it doesn’t find a content type and can’t guess the content type that utilized in the request for the resource. It is one of the most important reasons that show why content type label is one of the essential things.
Content Type Negotiation
A generic protocol is described by the HTTP specification for moving high fidelity information although we are inclined to reflect of HTTP as something that used to provide web pages. One should have to sure to include how to interpret the information and thus, the media type settings are significant. However, media types are not for hosts, clients are playing an important role in what media type a host returns by taking part in content type cooperation.
A single URL recognizes a resource that can have multiple representations. For example: we are presenting single recipe in multiple languages. This could even present recipe in different format, although the resources and content is same. Now, the question raises which representation should the server choose? The answer is the content negotiation mechanism that described by the HTTP specification.
At the time of clients creates and HTTP request to a URL, they have to specify the media types. These media types are the host to tag outgoing resources and also for clients to identify the media type they want to use. Talking about the web browsers, they are sophisticated pieces of software that deals with various resource representations. Moreover, many users would probably never care about content negotiation, but for software developers, it is a part of development that makes HTTP great.
Where We Stop?
In this post, we have learned URL, URL encoding, and content types deeply. After going through this part, you have to see what these content type specifications seem to be. Continue reading Part 2 for remaining information.