我是一個新的perl程序員,試圖將curl請求轉換爲使用LWP:UserAgent的Perl腳本。Perl LWP:UserAgent如何添加標題?
的捲曲請求的例子是:
curl -X GET -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" -H "Postman-Token: eb3955f1-a7b5-65d7-f5c0-808c7aba6cef" "https://10.51.10.26/10/download?startTime=1461698250&endTime=1461698252&cNat=True&cNatShowDst=True&tuplesFile=True&summarizeTuples=False"
我的PERL相當於:
use LWP::UserAgent;
my $browser = LWP::UserAgent->new;
my $url = 'https://10.51.10.26/10/download';
my @headers = (
"startTime" => $queryStart,
"endTime" => $queryEnd,
"cNat" => "True",
"cNatShowDst" => "False",
"tuplesFile" => "False",
"summarizeTuples" => "False",
"Authorization" => "Basic YWRtaW46YWRtaW4",
"Cache-Control" => "no-cache",
"Postman-Token" => "eb3955f1-a7b5-65d7-f5c0-808c7aba6cef",
);
結果 - HTTP::Response=HASH(0x27884bc)
這是添加頁眉的正確方法?
您沒有顯示完整的代碼。該代碼不會生成該輸出,因爲沒有發送發生。請參閱http://stackoverflow.com/documentation/perl/983/debug-output#t=201607270944292058065以瞭解如何輸出對象,以便了解它們。 – simbabque
請參考[導覽]瞭解如何將問題標記爲已解決。 :) – simbabque