First, OWIN
Second, Katana
Third, middleware middleware
First, OWIN
1,owin Introduction
Owin is open Web Server Interface for. NET acronym. Owin defines a standard set of interfaces between. Net Web server and Web application. The Owin target is used to decouple the Web server from the Web application. Owin is just a contract, a specification, not a code implementation (katana implements the Owin)
2,owin specification
1) Owin defines the host, Server, middleware, application four layers
①host: Primarily responsible for application configuration and startup processes, including initialization of Owin Pipeline (pipelines, including middleware), running server
②server: Binds the socket and listens for HTTP requests, and then encapsulates the body and header of the request and response into a dictionary that conforms to the Owin specification and is sent to the Owin middleware pipeline for processing
②middleware: Middleware, component, between server and application for processing requests sent to pipeline
④application: Specific application code
2) Application Delegate (application delegate) for server-to-middleware interaction. He is not a strict interface, but a delegate and each Owin middleware component must provide.
3) Environment Dictionary (Environment Dictionary), encapsulation of HTTP requests
Request data:
Required |
Key Name |
Value Description |
Yes |
"Owin. Requestbody " |
The request body. Stream type |
Yes |
"Owin. Requestheaders " |
The request header. idictionary<string, string[]> type |
Yes |
"Owin. Requestmethod " |
A string that contains the requested HTTP request method (for example, "GET", "POST"). |
Yes |
"Owin. Requestpath " |
A string that contains the request path. The path must be relative to the "root" of the application delegate. |
Yes |
"Owin. Requestpathbase " |
A string containing the request path part corresponding to the "root" of the application delegate |
Yes |
"Owin. Requestprotocol " |
A string that contains the protocol name and version (for example, "http/1.0" or "http/1.1"). |
Yes |
"Owin. Requestquerystring " |
String containing the query string component of the HTTP request URI, with no preamble "? (For example, "foo = Bar&baz = Quux"). The value may be an empty string. |
Yes |
"Owin. Requestscheme " |
String containing the URI scheme for the request (for example, "http", "https") |
Response data:
Required |
Key Name |
Value Description |
Yes |
"Owin. Responsebody " |
The response body. Stream type |
Yes |
"Owin. Responseheaders " |
The response header. idictionary<string, string[]> type |
No |
"Owin. Responsestatuscode " |
An optional option that contains the HTTP response status code defined in RFC 2616 section 6.1.1. The default value is 200. |
No |
"Owin. Responsereasonphrase " |
An optional string that contains the reason phrase is associated with the given status code. If not provided, the server should provide default values as specified in RFC 2616, section 6.1.1 |
No |
"Owin. Responseprotocol " |
An optional string that contains the protocol name and version (for example, "http/1.0" or "http/1.1"). If not provided, then "Owin. The value of the Requestprotocol "key is the default value. |
Other data:
Required |
Key Name |
Value Description |
Yes |
"Owin. Callcancelled " |
Indicates whether the request was canceled/aborted |
Yes |
"Owin. Version " |
Represents the Owin version of the string "1.0" |
Second, Katana
Third, middleware middleware
Owin and Katana