SsoClientHttpHelper

public class SsoClientHttpHelper
extends HttpHelper

java.lang.Object
   ↳ com.android.tradefed.util.net.HttpHelper
     ↳ com.google.android.tradefed.build.SsoClientHttpHelper


包含使用 sso 用戶端二進位檔提出 http 要求的輔助方法

摘要

公用建構函式

SsoClientHttpHelper()
SsoClientHttpHelper(String ssoClient, String certificate)

公用方法

HttpURLConnection createConnection(URL url, String method, String contentType)

Create a to given url.

HttpURLConnection createJsonConnection(URL url, String method)

Creates a connection to given URL for passing json data.

HttpURLConnection createXmlConnection(URL url, String method)

Creates a connection to given URL for passing xml data.

String doGet(String url)

針對指定網址執行 GET HTTP 要求方法,並以 String 形式傳回。

void doGetIgnore(String url)

針對指定網址執行 GET,並忽略結果 (使用指定網址參數)。

void doGetIgnoreWithRetry(String url)

Performs {doGetIgnore(String) retrying upon failure.

String doGetWithRetry(String url)

Performs {doGet(String) retrying upon failure.

String doPostWithRetry(String url, String postData, String contentType)

針對指定網址執行 POST HTTP 要求方法,並以 String 形式傳回,失敗時會重試。

受保護的方法

int parseHttpStatusCode(String httpStatusLine)

剖析 HTTP 狀態碼 (例如

String stripResponseHeader(String response)

從單一登入用戶端的 HTTP 回應中移除標頭,並傳回其主體。

String validateAndAdjustResponse(String response)

驗證並視需要調整 HTTP 回應。

公用建構函式

SsoClientHttpHelper

public SsoClientHttpHelper ()

SsoClientHttpHelper

public SsoClientHttpHelper (String ssoClient, 
                String certificate)

參數
ssoClient String

certificate String

公用方法

createConnection

public HttpURLConnection createConnection (URL url, 
                String method, 
                String contentType)

建立前往指定網址的連結。

參數
url URL:要連線的 URL

method String:HTTP 要求方法。例如 GET 或 POST。

contentType String:內容類型。例如「text/html」。

傳回
HttpURLConnection HttpURLConnection

擲回
IOException

createJsonConnection

public HttpURLConnection createJsonConnection (URL url, 
                String method)

建立與指定網址的連線,用於傳遞 JSON 資料。

參數
url URL:要連線的 URL

method String:HTTP 要求方法。例如 GET 或 POST。

傳回
HttpURLConnection HttpURLConnection

擲回
IOException

createXmlConnection

public HttpURLConnection createXmlConnection (URL url, 
                String method)

建立連線至指定網址,以傳遞 XML 資料。

參數
url URL:要連線的 URL

method String:HTTP 要求方法。例如 GET 或 POST。

傳回
HttpURLConnection HttpURLConnection

擲回
IOException

doGet

public String doGet (String url)

針對指定網址執行 GET HTTP 要求方法,並以 String 形式傳回。

由於系統會將遠端內容載入記憶體,因此這個方法只適用於相對較小的資料大小。

參考資料:

參數
url String:網址

傳回
String String 遠端內容

擲回
IHttpHelper.DataSizeException
IOException

doGetIgnore

public void doGetIgnore (String url)

針對指定網址執行 GET,並忽略結果 (使用指定網址參數)。

參數
url String:網址

擲回
IOException

doGetIgnoreWithRetry

public void doGetIgnoreWithRetry (String url)

如果失敗,會執行 {doGetIgnore(String) 重試。

參數
url String:網址

擲回
IOException

doGetWithRetry

public String doGetWithRetry (String url)

如果失敗,會執行 {doGet(String) 重試。

參數
url String:網址

傳回
String String 遠端內容

擲回
IHttpHelper.DataSizeException
IOException

doPostWithRetry

public String doPostWithRetry (String url, 
                String postData, 
                String contentType)

針對指定網址執行 POST HTTP 要求方法,並以 String 形式傳回,失敗時會重試。

由於系統會將遠端內容載入記憶體,因此這個方法只適用於相對較小的資料大小。

參數
url String:網址

postData String:連線開啟後要發布的資料

contentType String:內容類型。例如「text/html」。

傳回
String String 遠端內容

擲回
IHttpHelper.DataSizeException
IOException

受保護的方法

parseHttpStatusCode

protected int parseHttpStatusCode (String httpStatusLine)

剖析 HTTP 狀態碼 (例如 200) (例如 HTTP/1.1 200 OK)

參數
httpStatusLine String

傳回
int

另請參閱:

stripResponseHeader

protected String stripResponseHeader (String response)

從單一登入用戶端的 HTTP 回應中移除標頭,並傳回其主體。

參數
response String

傳回
String

validateAndAdjustResponse

protected String validateAndAdjustResponse (String response)

驗證並視需要調整 HTTP 回應。

參數
response String

傳回
String