使用程式傳送http請求

2021-09-02 16:38:10 字數 823 閱讀 5558

需要jar包:

commons-logging.jar(或許不需要)

或依賴:

//先建立乙個連線物件

;//建立請求方法

;//請求引數物件

namevaluepair[

] params =

newnamevaluepair

;//把請求引數設定到請求方法裡

postmethod.

setquerystring

(params)

;//執行請求

client.

executemethod

(postmethod)

;//獲取請求相應

string str = postmethod.

getresponsebodyasstring()

;

使用scoket傳送HTTP請求

建議先看一下如何用telnet傳送http請求 此方法負責寫請求行 如 get index.php http 1.1 private function setline method 此方法負責寫頭資訊 如host localhost public function setheader key,val...

python 傳送http請求

測試用cgi,名字為test.py,放在apache的cgi bin目錄下 usr bin python import cgi def main print content type text html n form cgi.fieldstorage if form.has key servicec...

PHP 傳送HTTP請求

file get contents版本 傳送post請求 param string url 請求位址 param array post data post鍵值對資料 return string function send post url,post data 使用如下 post data array...