锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
Architectural Styles and the Design of Network-based Software Architectures銆by銆Roy Thomas Fielding
銆銆銆銆銆銆Doctor of Philosophy in Information and Computer Science
銆銆銆銆銆銆University of California, Irvine, 2000
銆銆銆銆銆銆Professor Richard N. Taylor, Chair
銆銆The World Wide Web has succeeded in large part because its software architecture has
been designed to meet the needs of an Internet-scale distributed hypermedia system. The
Web has been iteratively developed over the past ten years through a series of
modifications to the standards that define its architecture. In order to identify those aspects
of the Web that needed improvement and avoid undesirable modifications, a model for the
modern Web architecture was needed to guide its design, definition, and deployment.
銆銆Software architecture research investigates methods for determining how best to
partition a system, how components identify and communicate with each other, how
information is communicated, how elements of a system can evolve independently, and
how all of the above can be described using formal and informal notations. My work is
motivated by the desire to understand and evaluate the architectural design of networkbased
application software through principled use of architectural constraints, thereby
obtaining the functional, performance, and social properties desired of an architecture. An
architectural style is a named, coordinated set of architectural constraints.
銆銆This dissertation defines a framework for understanding software architecture via
architectural styles and demonstrates how styles can be used to guide the architectural
design of network-based application software. A survey of architectural styles for
network-based applications is used to classify styles according to the architectural
properties they induce on an architecture for distributed hypermedia. I then introduce the
Representational State Transfer (REST) architectural style and describe how REST has
been used to guide the design and development of the architecture for the modern Web.
銆銆REST emphasizes scalability of component interactions, generality of interfaces,
independent deployment of components, and intermediary components to reduce
interaction latency, enforce security, and encapsulate legacy systems. I describe the
software engineering principles guiding REST and the interaction constraints chosen to
retain those principles, contrasting them to the constraints of other architectural styles.
Finally, I describe the lessons learned from applying REST to the design of the Hypertext
Transfer Protocol and Uniform Resource Identifier standards, and from their subsequent
deployment in Web client and server software.
Roy Thomas Fielding鍗氬+璁烘枃鑻辨枃鐗堟湰銆http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm
]]>
<request line>
<headers>
<blank line>
[<request-body>]
鍦?/span>HTTP璇鋒眰涓紝絎竴琛屽繀欏繪槸涓涓姹傝錛?/span>request line錛夛紝鐢ㄦ潵璇存槑璇鋒眰綾誨瀷銆佽璁塊棶鐨?nobr oncontextmenu="return false;" onmousemove="kwM(11);" id="key6" onmouseover="kwE(event,11, this);" style="color: #6600ff; border-bottom: #6600ff 1px dotted; background-color: transparent; text-decoration: underline" onclick="return kwC();" onmouseout="kwL(event, this);" target="_blank">璧勬簮浠ュ強浣跨敤鐨?/span>HTTP鐗堟湰銆傜揣鎺ョ潃鏄竴涓閮紙header錛夊皬鑺傦紝鐢ㄦ潵璇存槑鏈嶅姟鍣ㄨ浣跨敤鐨勯檮鍔犱俊鎭傚湪棣栭儴涔嬪悗鏄竴涓┖琛岋紝鍐嶆涔嬪悗鍙互娣誨姞浠繪剰鐨勫叾浠栨暟鎹?/span>[縐頒箣涓轟富浣擄紙body錛?/span>]銆?/span>
HTTP 瀹氫箟浜嗕笌鏈嶅姟鍣ㄤ氦浜掔殑涓嶅悓鏂規硶錛屾渶鍩烘湰鐨勬柟娉曟槸 GET 鍜?/span> POST錛?/span>Ajax
GET涓?/span>POST鏂規硶鏈変互涓嬪尯鍒細
錛?錛?span style="font: 7pt 'Times New Roman'"> 鍦ㄥ鎴風錛?/span>Get鏂瑰紡鍦ㄩ氳繃URL鎻愪氦鏁版嵁錛屾暟鎹?/span>鍦?/span>URL涓彲浠ョ湅鍒幫紱POST鏂瑰紡錛屾暟鎹斁緗湪HTML HEADER鍐呮彁浜ゃ?/span>
錛?錛?span style="font: 7pt 'Times New Roman'"> GET鏂瑰紡鎻愪氦鐨勬暟鎹渶澶氬彧鑳芥湁1024瀛楄妭錛岃?/span>POST鍒欐病鏈夋闄愬埗銆?/span>
錛?錛?span style="font: 7pt 'Times New Roman'"> 瀹夊叏鎬ч棶棰樸傛濡傚湪錛?/span>1錛変腑鎻愬埌錛屼嬌鐢?/span> Get 鐨勬椂鍊欙紝鍙傛暟浼氭樉紺哄湪鍦板潃鏍忎笂錛岃?/span> Post 涓嶄細銆傛墍浠ワ紝濡傛灉榪欎簺鏁版嵁鏄腑鏂囨暟鎹屼笖鏄潪鏁忔劅鏁版嵁錛岄偅涔堜嬌鐢?/span> get錛涘鏋滅敤鎴瘋緭鍏ョ殑鏁版嵁涓嶆槸涓枃瀛楃鑰屼笖鍖呭惈鏁忔劅鏁版嵁錛岄偅涔堣繕鏄嬌鐢?/span> post涓哄ソ銆?/span>
錛?錛?span style="font: 7pt 'Times New Roman'"> 瀹夊叏鐨勫拰騫傜瓑鐨勩傛墍璋撳畨鍏ㄧ殑鎰忓懗鐫璇ユ搷浣滅敤浜庤幏鍙栦俊鎭岄潪淇敼淇℃伅銆傚箓絳夌殑鎰忓懗鐫瀵瑰悓涓 URL 鐨勫涓姹傚簲璇ヨ繑鍥炲悓鏍風殑緇撴灉銆傚畬鏁寸殑瀹氫箟騫朵笉鍍忕湅璧鋒潵閭f牱涓ユ牸銆傛崲鍙ヨ瘽璇達紝GET 璇鋒眰涓鑸笉搴斾駭鐢熷壇浣滅敤銆備粠鏍規湰涓婅錛屽叾鐩爣鏄綋鐢ㄦ埛鎵撳紑涓涓摼鎺ユ椂錛屽ス鍙互紜俊浠庤嚜韜殑瑙掑害鏉ョ湅娌℃湁鏀瑰彉璧勬簮銆傛瘮濡傦紝鏂伴椈绔欑偣鐨勫ご鐗堜笉鏂洿鏂般傝櫧鐒剁浜屾璇鋒眰浼氳繑鍥炰笉鍚岀殑涓鎵規柊闂伙紝璇ユ搷浣滀粛鐒惰璁や負鏄畨鍏ㄧ殑鍜屽箓絳夌殑錛屽洜涓哄畠鎬繪槸榪斿洖褰撳墠鐨勬柊闂匯傚弽涔嬩害鐒躲?/span>POST 璇鋒眰灝變笉閭d箞杞繪澗浜嗐?/span>POST 琛ㄧず鍙兘鏀瑰彉鏈嶅姟鍣ㄤ笂鐨勮祫婧愮殑璇鋒眰銆備粛鐒朵互鏂伴椈绔欑偣涓轟緥錛岃鑰呭鏂囩珷鐨勬敞瑙e簲璇ラ氳繃 POST 璇鋒眰瀹炵幇錛屽洜涓哄湪娉ㄨВ鎻愪氦涔嬪悗绔欑偣宸茬粡涓嶅悓浜嗭紙姣旀柟璇存枃绔犱笅闈㈠嚭鐜頒竴鏉℃敞瑙o級銆?br /> http://www.cnblogs.com/stu-acer/archive/2006/08/28/488802.html
GET涓?/span>POST鏂規硶瀹炰緥錛?br />
GET /books/?name=Professional%20Ajax HTTP/1.1 Host: www.wrox.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050225 Firefox/1.0.1 Connection: Keep-Alive POST / Host: www.wrox.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20050225 Firefox/ Content-Type: application/x-www-form-urlencoded Content-Length: 40 Connection: Keep-Alive name=Professional%20Ajax&publisher=Wiley
GET瀹炰緥
POST瀹炰緥
錛堟澶勭┖涓琛岋級
錛?/span>1錛?/span>get鏄粠鏈嶅姟鍣ㄤ笂鑾峰彇鏁版嵁錛?/span>post鏄悜鏈嶅姟鍣ㄤ紶閫佹暟鎹?/span>
錛?/span>2錛夊浜庤〃鍗曠殑鎻愪氦鏂瑰紡錛?/span>鍦ㄦ湇鍔″櫒绔彧鑳界敤Request.QueryString鏉ヨ幏鍙?/span>Get鏂瑰紡鎻愪氦鏉ョ殑鏁版嵁錛岀敤Post鏂瑰紡鎻愪氦鐨勬暟鎹彧鑳界敤Request.Form鏉ヨ幏鍙栥?/span>
錛?/span>3錛変竴鑸潵璇達紝灝介噺閬垮厤浣跨敤Get鏂瑰紡鎻愪氦琛ㄥ崟錛屽洜涓烘湁鍙兘浼氬鑷村畨鍏ㄩ棶棰樸傛瘮濡傝鍦ㄧ櫥闄嗚〃鍗曚腑鐢?/span>Get鏂瑰紡錛岀敤鎴瘋緭鍏ョ殑鐢ㄦ埛鍚嶅拰瀵嗙爜灝嗗湪鍦板潃鏍忎腑鏆撮湶鏃犻仐銆備絾鏄湪鍒嗛〉紼嬪簭涓紝鐢?/span>Get鏂瑰紡灝辨瘮鐢?/span>Post濂姐?/span>
<status line>
<headers>
<blank line>
[<response-body>]
鍦ㄥ搷搴斾腑鍞竴鐪熸鐨?span style="color: red">鍖哄埆鍦ㄤ簬絎竴琛屼腑鐢ㄧ姸鎬?nobr oncontextmenu="return false;" onmousemove="kwM(1);" id="key1" onmouseover="kwE(event,1, this);" style="color: #6600ff; border-bottom: #6600ff 1px dotted; background-color: transparent; text-decoration: underline" onclick="return kwC();" onmouseout="kwL(event, this);" target="_blank">淇℃伅浠f浛浜嗚姹備俊鎭?span style="color: red">鐘舵佽錛?/span>status line錛夐氳繃鎻愪緵涓涓姸鎬佺爜鏉ヨ鏄庢墍璇鋒眰鐨勮祫婧愭儏鍐點?/span>
HTTP鍝嶅簲瀹炰緥錛?/span>
HTTP/1.1 200 OK Date: Sat, 31 Dec 2005 23:59:59 GMT Content-Type: text/html;charset=ISO-8859-1 Content-Length: 122 錛?/span>html錛?/span> 錛?/span>head錛?/span> 錛?/span>title錛?/span>Wrox Homepage錛?/span>/title錛?/span> 錛?/span>/head錛?/span> 錛?/span>body錛?/span> 錛?/span>!-- body goes here --錛?/span> 錛?/span>/body錛?/span> 錛?/span>/html錛?/span>
鈼?/span>200 (OK): 鎵懼埌浜嗚璧勬簮錛屽茍涓斾竴鍒囨甯搞?/span>
鈼?/span>304 (NOT MODIFIED): 璇ヨ祫婧愬湪涓婃璇鋒眰涔嬪悗娌℃湁浠諱綍淇敼銆傝繖閫氬父鐢ㄤ簬嫻忚鍣ㄧ殑緙撳瓨鏈哄埗銆?/span>
鈼?/span>401 (UNAUTHORIZED):
鈼?/span>403 (FORBIDDEN): 瀹㈡埛绔湭鑳借幏寰楁巿鏉冦傝繖閫氬父鏄湪401涔嬪悗杈撳叆浜嗕笉姝g‘鐨勭敤鎴峰悕鎴栧瘑鐮併?/span>
鈼?/span>404 (NOT FOUND): 鍦ㄦ寚瀹氱殑浣嶇疆涓嶅瓨鍦ㄦ墍鐢寵鐨?nobr oncontextmenu="return false;" onmousemove="kwM(7);" id="key5" onmouseover="kwE(event,7, this);" style="color: #6600ff; border-bottom: 0px dotted; background-color: transparent; text-decoration: underline" onclick="return kwC();" onmouseout="kwL(event, this);" target="_blank">璧勬簮銆?/span>