




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、Http 一、Http 協(xié)議入httphttp 協(xié)議: 對瀏覽器客戶端 和 服務(wù)器端 之間二Http 一、Http 協(xié)議入httphttp 協(xié)議: 對瀏覽器客戶端 和 服務(wù)器端 之間二、查http 協(xié)議的工2)使用谷歌的http協(xié)議響應(yīng)(服務(wù)器-瀏覽器HTTP/1.1200Content-Length: 24Date:Fri,30Jan201501:54:57thisoGET /day09/ o HTTP/1.1 Host: localhost:8080User-Agent:Mozilla/5.0(WindowsNT6.1;WOW64;rv:35.0)Gecko/20100101Firefox
2、/35.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Encoding: gzip, deflate 四、Http3.1 GETo#http#請求資資源標(biāo)記符。四、Http3.1 GETo#http#請求資資源標(biāo)記符。o(/0/myweb/indx.html# T、HEAD、TRACE、PUT、CONNECT 常用的請求方式: TGEToHost:User-Agent:Mozilla/5.0(WindowsNT6.1;WOW64;rv:35.0)Gecko/20100101Fire
3、fox/35.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Encoding: gzip, deflate formaction=提交地址T formaction=提交地址T c)GET。T 3.2 Accept:- : - Host: localhost:8080User-Agent:Mozilla/5.0(WindowsNT6.1;WOW64;rv:35.0)Gecko/20100101Firefox/35.0 Accept: text/html,application/xht
4、ml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Encoding: gzip, deflateConnection:keep-Host: localhost:8080User-Agent:Mozilla/5.0(WindowsNT6.1;WOW64;rv:35.0)Gecko/20100101Firefox/35.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Encoding: gzip, deflateConnection:keep-3.
5、3 實體 3.4HttpServletRequest 3.3 實體 3.4HttpServletRequest 實體內(nèi)容3.5service doXX 方法區(qū)HttpSevlet類的源碼protectedvoidservice(HttpServletRequestreq,HttpServletResponse throwsServletException,IOExceptionAccept-Language:en-us,zh-If-Modified-Since: Tue, 11 Jul 2000 18:23:51 GMT- 當(dāng)前請求來自于哪里User-Agent:Mozilla/4.0comp
6、atibleMSIE5.5;WindowsNT- 瀏覽器保存Connection: close/Keep- 瀏覽器跟服務(wù)器連接狀態(tài)。close: Date:Tue11Jul200018:23:51- /得到請求方/得到請求方Stringmethod=if (method.equals(METHOD_GET) longlastModified=if(lastModified=-1)/servletdoesntsupportif-modified-since,no/togothroughfurtherexpensivelogic doGet(req, resp);elselongtryifModi
7、fiedSince = catch(IllegalArgumentExceptioniae)/ Invalid date header - proceed as if nifModifiedSince = -1;if(ifModifiedSince(lastModified/1000*1000)/Iftheservletmodtimeislater,call/Rounddowntothenearestsecondfora/AifModifiedSinceof-1willalwaysbeless maybeSetLastModified(resp, lastModified); doGet(re
8、q, resp);elseelseif long lastModified = doHead(req, resp);elseift(req,elseifdoPut(req,elseif案例時間 案例防1 2 :案例時間 案例防1 2 :)代碼elseifelseifelse/tthismeansNOservletsupports/methodwasrequested,anywhereonthisStringerrMsgObject errArgs = new Object1; errArgs0 = method;errMsg=MessageFormat.format(errMsg,3.8 傳遞
9、的請求參數(shù)如何GET3.8 傳遞的請求參數(shù)如何GETURIT TpublicclassImgFilterimplementsFilterpublicvoiddestroy()/TODOAuto-generatedmethodpublicvoiddoFilter(ServletRequestservletRequest,ServletResponse servletResponse, FilterChain filterChain)throwsIOException,ServletExceptionHttpServletRequest request = (HttpServletRequest)
10、 servletRequest; HttpServletResponseresponse=(HttpServletResponse)servletResponse; String referer = request.getHeader(referer);ln(referis+ if(referer=null| elsefilterChain.doFilter(request,publicvoidinit(FilterConfigarg0)throwsServletException/TODOAuto-generatedmethod。的 API: 取多個值的參數(shù)Http響應(yīng)#http 協(xié)議。的
11、API: 取多個值的參數(shù)Http響應(yīng)#http 協(xié)議#狀態(tài)碼: 服務(wù)器處理請求的結(jié)果(狀態(tài)200 #常見的響應(yīng) HTTP/1.1200Server: Apache-Coyote/1.1Content-Length: 24Date:Fri,30Jan201501:54:57thiso5.3HttpServletResponse對 5.3HttpServletResponse對 5.4 案例- 請求重定向resp.setHeader(Location,Server:apache: - : Content-Type: text/html; charset=GB2312Last-Modified: T
12、ue, 11 Jul 2000 18:23:51 GMTRefresh: 1;url=ition:attaent; filename=aaa.zip -表示告訴瀏覽器以:SS=Q0=5Lb_nQ; path=/searchExpires:1Cache-Controlno-cachePragma:no-Connection: close/Keep-Alive接 keep-alive:保存連接六、Https6.1.1http6.1.2https六、Https6.1.1http6.1.2https都知道 HTTPS 能夠加密信息,以免敏感信息被第級別較高的服務(wù)都會采用 HTTPS 協(xié)議。客戶端在使用
13、HTTPS 方式與Web 服務(wù)器通信時有以下幾個步驟客戶使用https 的Web 服務(wù)器,要求與Web 服務(wù)器建立SSL 連接Web 服務(wù)器收到客戶端請求后,會信息Web SSL Web 服務(wù)器利用自己的私 1、https 協(xié)議需要到ca 申2、http 是超文本傳輸協(xié)議,信息是明文傳輸,https ssl 3、http https 804434、http 的連接很簡單,是無狀態(tài)的;HTTPS SSL+HTTP 協(xié)議構(gòu)建的可進行加密傳輸、認證的網(wǎng)絡(luò)協(xié)議,比 http 協(xié)議安全。6.1.3https雖然說HTTPS6.1.3https雖然說HTTPS 有很大的優(yōu)勢,但其相對來說,還是存HTTPS
14、 50%10% 20% HTTPS HTTP 高效,會增加數(shù)據(jù)開銷和功耗,甚至已有的安全措施也會因此而受通常需要綁定IP,不能在同一IP 上綁定多,IPv4 資源不可能支撐這個消耗HTTPS 協(xié)議的加密范圍也比較有限,在到什么作用。最關(guān)鍵的的信用鏈體系并不安全,特別是在某些國家可以控制CA 的情七、http 請求工7.1 客戶端模七、http 請求工7.1 客戶端模擬http請求工tmen(谷歌插件)、RestC 7.2 服務(wù)器模擬http請求工httpc nt、httpCient* 發(fā)t請本地應(yīng)用并根據(jù)傳遞參數(shù)不同返回不同結(jié)publict()/ 創(chuàng)建默認的nt實例ntnt=/創(chuàng)建tt=Lis
15、tformparams=newArrayList(); ameValuePair(type, house); UrlEncodedFormEntity uefEntity;tryuefEntity=newUrlEncodedFormEntity(formparams,UTF-8); ln(executing request + httpCloseableHttpResponse response = httpctry HttpEntityentity=response.getEntity(); if (entity != null) ln(Responsecontent:+ EntityUti
16、ls.toString(entity, UTF-8);finallycatchntProtocolException catch(UnsupportedEncodingExceptioncatch(UnsupportedEncodingException catch(IOException finally/ 關(guān)閉連接資 catch(IOException *發(fā)送get請publicvoidget()nt httpcnt = HttpCtry 創(chuàng)建HttpGet httpget = new HttpGet(htln(executingrequest+httpget.getURI();執(zhí)行g(shù)et請
17、求CloseableHttpResponse response = httpctry HttpEntityentity=打印響應(yīng)狀if (entity != null) / 打印響應(yīng)內(nèi)容長ln(Responsecontentlength:+ ln(Responsecontent:+ finallyajax跨域?qū)崙?zhàn)解決方 。annotajax跨域?qū)崙?zhàn)解決方 。annotload type:ype:url : data : userName=余勝軍&userAge=19,s:function(msg) catch(ParseException catch(IOException finally/
18、關(guān)閉連接資 catch(IOException 使 response 添加header *); 支持使 response 添加header *); 支持有前端代碼后端代碼publicclassFromUserServletextendsHttpServletprotectedvoiddoGet(HttpServletRequestreq,HttpServletResponseresp)throws ServletException, IOException t(req,protected void dot(HttpServletRequestreq,HttpServletResponseresp)throws ServletException, IOException /s-Control-Allow-Origin,ty
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 綠蓮蓬創(chuàng)意畫課件
- 我的學(xué)校繪畫課件
- 經(jīng)濟法概論考試高效復(fù)習(xí)寶典試題及答案
- 創(chuàng)意斑馬美術(shù)課件
- 酒店餐飲服務(wù)質(zhì)量試卷
- 4S店新車銷售和售后維修合同
- 經(jīng)濟師考試復(fù)習(xí)指導(dǎo)手冊試題及答案
- 眼睛管理知識培訓(xùn)課件
- 語言學(xué)語法結(jié)構(gòu)分析試卷
- 行政管理專科公共關(guān)系案例分析題目及試題及答案
- 2024年江西省高考化學(xué)試卷(真題+答案)
- 大美勞動智慧樹知到期末考試答案章節(jié)答案2024年江西財經(jīng)大學(xué)
- 建筑史智慧樹知到期末考試答案2024年
- 醫(yī)院實驗室生物安全管理手冊范本
- 蘇教版譯林小學(xué)英語人物Word可打印頭像
- 化驗員培訓(xùn)-實驗室建設(shè)課件
- 工作票票樣(配電)模板
- AS1657-1992---固定平臺、走道、樓梯與梯子的設(shè)計、施工與安裝
- 地形圖的識別及應(yīng)用與涉密地圖的保密管理(課堂PPT)
- 機電傳動控制期末考試試卷試題及答案
- 電大漢語言文學(xué)專業(yè)本科社會實踐調(diào)查報告
評論
0/150
提交評論