HTTP 2.0
HTTP 2.0 is the next planned version of the HTTP protocol specification and is an attempt to optimize the usage of network resources and reduce latency through header compressions and pooling multiple connections over the same channels. The initiative is spearheaded by Google and Mozilla research teams and as of today, is in a working draft state. The good news is that HTTP 2.0 is going to retain all the goodness of HTTP 1.1 while making it more performant over the wire through efficient processing of messages. Since HTTP 2.0 is still in the making, we will refrain from using it for the scope of this book. However, if you are enthusiastic to know more about HTTP 2.0, you can take a look at the current draft of the specification at http://http2.github.io/http2-spec/.
For the scope of this book, HTTP always refers to HTTP 1.1 specification of the protocol.
HTTP and .NET
Starting from .NET 4.5, a new namespace and assembly was added as part of the framework, System.Net.Http
. The resemblance of the types in this namespace may look behaviorally similar to those defined in ASP.NET System.Web.Http
namespace; however, the addition of this namespace marks a big difference in the development of HTTP services.
Firstly, it enables unified communication over HTTP by providing a set of abstract types. These types allow any .NET application to access HTTP services in a consistent way, for example, now both the client and server can use the same HTTP programming model for better development experience. Secondly, it has been written to target modern HTTP apps such as Web API and mobile development, this signifies the investment of Microsoft in making HTTP services a first-class citizen.
Some of the key types defined in this namespace are:
Type |
Description |
---|---|
|
This enables primitive operations for sending HTTP requests and receiving HTTP responses from a resource identified by a URI. |
|
This represents the HTTP request message from a client. |
|
This represents the HTTP response message received from an HTTP request. |
|
This is a base class that represents an HTTP entity body and any content headers. |
|
This is the base type for all message handlers and this will be used to define all message handlers. Message handlers may be used to create server-side or client-side handlers. The server-side handler works with the hosted model chain and handles incoming client requests ( The We may, of course, hook our custom controllers in the pipelines, for example, to validate, modify, or log the requests. |
Note
For a complete list of all types available in the System.Net.Http
namespace, please visit http://msdn.microsoft.com/en-us/library/system.net.http(v=vs.110).aspx.
We will see in the later sections that the ASP.NET Web API also leverages some of the System.Net.Http
types for communication over HTTP.