1 / 18

第四章 瀏覽器

第四章 瀏覽器. 4-1 HTTP 通訊協定 4-2 請求與回應 4-3 瀏覽器. 第四章 瀏覽器. 4-1 HTTP 通訊協定. 瀏覽網頁. 使用 WWW ( World Wide Web )的應用。 HTTP ( Hyper Text Transfer Protocol )。 MIME ( Multipurpose Internet Mail Extension )。 URL ( Uniform Resource Locator )。 URI ( Uniform Resource Identifier )。. HTTP 通訊協定.

Download Presentation

第四章 瀏覽器

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第四章 瀏覽器 • 4-1 HTTP通訊協定 • 4-2 請求與回應 • 4-3瀏覽器

  2. 第四章 瀏覽器 4-1 HTTP通訊協定

  3. 瀏覽網頁 • 使用WWW(World Wide Web)的應用。 • HTTP(Hyper Text Transfer Protocol)。 • MIME(Multipurpose Internet Mail Extension)。 • URL(Uniform Resource Locator)。 • URI(Uniform Resource Identifier)。

  4. HTTP通訊協定 • 用戶端瀏覽器與網站伺服器之間的溝通標準。 • 定義在網路的應用層。 • 用戶端發出瀏覽網頁的需求,經由TCP的連線,傳送至Web Server,並回應適當的HTTP訊息。

  5. HTTP通訊協定 • 用戶端傳送標題資訊和HTTP方法給伺服器 • HTTP通訊協定可以:(由伺服器傳回) • 瀏覽文字、影像與HTML等靜態網頁。 • 可在網頁嵌入Plug In元件,JAVA元件與AJAX技術,讓網頁從靜態網頁動態網頁主動式網頁。

  6. HTTP標題資訊 • 先把HTTP請求轉換標題資訊傳送至網站伺服器去處理。 GET / HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */* Accept-Language: zh-tw Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) Host: 127.0.0.1:90 Connection: Keep-Alive

  7. HTTP方法

  8. HTTP方法 • GET方法 • 取得URI所指定的資源。例如:http://www.csie.isu.edu.tw/index.html • HEAD方法 • 伺服器傳回內容包括標題與內容 • POST方法 • 客戶端所傳訊息包括參數或物件的查詢條件

  9. HTTP通訊協定的訊息代碼

  10. 第四章 瀏覽器 4-2 請求與回應

  11. 網路的請求與回應的模型

  12. WebRequest與WebResponse • 定義在System.Net的命名空間。 • WebRequest類別: • 處理用戶端的需求。 • WebResponse類別: • 伺服端的回應。

  13. 使用WebRequest與WebResponse來取得指定網址的內容 '設定網站伺服器的網址 Dim request As WebRequest = WebRequest.Create(WebSiteTextBox.Text) '設定逾時時間(毫秒) request.Timeout = 10000 '取得回應物件 Dim response As WebResponse = request.GetResponse '取得回應的資料流 Dim content As Stream = response.GetResponseStream Dim data(256) As Byte Dim HtmlPageContent As String = "" Dim dataRead As Integer = 0 '開始讀取資料 Do dataRead = content.Read(data, 0, 256) HtmlPageContent += Encoding.Default.GetString(data, 0, 256) Loop While dataRead > 0

  14. WebClient類別 • 義在System.Net命名空間。 • 用來對指定的URI資源,進行關連的內容之上傳或下載。 • 可替代WebRequest類別與WebResponse類別,實作網頁內容下載的方法。

  15. 使用WebClient類別下載網頁內容 '建立WebClient類別的執行個體 Dim myWebClient As New WebClient() '下載網頁的資料 Dim myDatabuffer As Byte() = myWebClient.DownloadData(顯示物件)

  16. 使用WebClient類別下載資源 ‘建立WebClient類別的執行個體 Dim MyWebClient As New WebClient() ‘下載資源 MyWebClient.DownloadFile(下載資源, 儲存檔名)

  17. 第四章 瀏覽器 4-3瀏覽器

  18. WebBrowse類別 • 從.NET Framework 2.0開始支援。 • 定義在System.Windows.Forms的命名空間。 • 實作瀏覽器。

More Related