あなたはの出力を投稿しませんでした。
またCONTENT_LENGTHは、すべてのデータは、このように値がない、キー/値ペアのキー一部として使用され、そしていかなる値は、コンテンツの長さを有していないためだ0
あります0
のにもかかわらず、サーバはヘッダを受信すべきではありません。
Content_Type = "form-data"
生の要求のために、私が手:
POST http://thehost.com
Connection: Keep-Alive
Accept-Encoding: wav
Accept-Language: en-us
Host: www.mydomain.com
Referer: hxxp://www.mydomain.com/some.php3
User-Agent: Mozilla/4.0
Content-Length: 82
Content-Type: multipart/form-data; boundary=xYzZY
--xYzZY
Content-Disposition: form-data; name="mydata"
hello world
--xYzZY--
明らかにわかるように、Content-Typeヘッダーはmultipart/form-data
です。これは、
のコンテンツタイプをリクエストヘッダーの1つとして指定することによってトリガーします。
つまり、perlモジュールは、実際の要求にヘッダContent-Type: multipart/form-data
を作成します。ここで
は、私が使用したコードです:
use strict;
use warnings;
use 5.020;
use Data::Dumper;
use HTTP::Message;
use HTTP::Request::Common;
my $rawdata = "hello world";
my $url = "http://thehost.com";
my $requ = POST $url,
Referer => 'hxxp://www.mydomain.com/some.php3',
Accept_Language => 'en-us',
Content_Type => 'form-data',
Accept_Encoding => 'wav',
User_Agent => 'Mozilla/4.0',
Host => 'www.mydomain.com',
Connection => 'Keep-Alive',
Content => [ mydata => $rawdata ];
say $requ->as_string;
次のキー/値のペアvを指定するとの違いを示すだけの値を指定:。
use strict;
use warnings;
use 5.020;
use Data::Dumper;
use HTTP::Message;
use HTTP::Request::Common;
my $rawdata = "hello world";
my $url = "http://thehost.com";
my $requ = POST $url,
Referer => 'hxxp://www.mydomain.com/some.php3',
Accept_Language => 'en-us',
Content_Type => 'form-data',
Accept_Encoding => 'wav',
User_Agent => 'Mozilla/4.0',
Host => 'www.mydomain.com',
Connection => 'Keep-Alive',
Content => [
mykey => 'myValue',
$rawdata,
];
say $requ->as_string;
--output:--
POST http://thehost.com
Connection: Keep-Alive
Accept-Encoding: wav
Accept-Language: en-us
Host: www.mydomain.com
Referer: hxxp://www.mydomain.com/some.php3
User-Agent: Mozilla/4.0
Content-Length: 142
Content-Type: multipart/form-data; boundary=xYzZY
--xYzZY
Content-Disposition: form-data; name="mykey" #<===HERE
myValue #<======AND HERE
--xYzZY
Content-Disposition: form-data; name="hello world" #<===COMPARED TO
#<======COMPARED TO
--xYzZY--
裸値が使用されてしまいます値として存在しないため、Content-Lengthは0になります。docsによると、ここでファイルのアップロードを指定する必要がありますどのように
されています:
use strict;
use warnings;
use 5.020;
use Data::Dumper;
use HTTP::Message;
use HTTP::Request::Common;
my $rawdata = "hello world";
my $url = "http://thehost.com";
my $requ = POST $url,
Referer => 'hxxp://www.mydomain.com/some.php3',
Accept_Language => 'en-us',
Content_Type => 'form-data',
Accept_Encoding => 'wav',
User_Agent => 'Mozilla/4.0',
Host => 'www.mydomain.com',
Connection => 'Keep-Alive',
Content => [
mykey => 'myValue', #some other key/value pair
cool_sounds => [undef, #file upload key/value pair
'myfile.wav',
Content => $rawdata
]
];
say $requ->as_string;
--output:--
POST http://thehost.com
Connection: Keep-Alive
Accept-Encoding: wav
Accept-Language: en-us
Host: www.mydomain.com
Referer: hxxp://www.mydomain.com/some.php3
User-Agent: Mozilla/4.0
Content-Length: 176
Content-Type: multipart/form-data; boundary=xYzZY
--xYzZY
Content-Disposition: form-data; name="mykey"
myValue
--xYzZY
Content-Disposition: form-data; name="cool_sounds"; filename="myfile.wav"
hello world
--xYzZY--
ファイルセクション用のContent-Typeを設定する必要がある場合、あなたはこのようにそれを行うことができます。
use strict;
use warnings;
use 5.020;
use Data::Dumper;
use HTTP::Message;
use HTTP::Request::Common;
my $rawdata = "hello world";
my $url = "http://thehost.com";
my $requ = POST $url,
Referer => 'hxxp://www.mydomain.com/some.php3',
Accept_Language => 'en-us',
Content_Type => 'form-data',
Accept_Encoding => 'wav',
User_Agent => 'Mozilla/4.0',
Host => 'www.mydomain.com',
Connection => 'Keep-Alive',
Content => [
mykey => 'myValue', #some other key/value pair
cool_sounds => [undef, #file upload key/value pair
'myfile.wav',
'Content-Type' => 'audio/x-wav',
Content => $rawdata
] #=>If one of the values in the $form_ref is an array reference...
];
say $requ->as_string;
--output:--
OST http://thehost.com
Connection: Keep-Alive
Accept-Encoding: wav
Accept-Language: en-us
Host: www.mydomain.com
Referer: hxxp://www.mydomain.com/some.php3
User-Agent: Mozilla/4.0
Content-Length: 203
Content-Type: multipart/form-data; boundary=xYzZY
--xYzZY
Content-Disposition: form-data; name="mykey"
myValue
--xYzZY
Content-Disposition: form-data; name="cool_sounds"; filename="myfile.wav"
Content-Type: audio/x-wav
hello world
--xYzZY--
そして、あなたは他の何かにファイルセクションの内容-処分を設定する必要がある場合:
use strict;
use warnings;
use 5.020;
use Data::Dumper;
use HTTP::Message;
use HTTP::Request::Common;
my $rawdata = "hello world";
my $url = "http://thehost.com";
my $requ = POST $url,
Referer => 'hxxp://www.mydomain.com/some.php3',
Accept_Language => 'en-us',
Content_Type => 'form-data',
Accept_Encoding => 'wav',
User_Agent => 'Mozilla/4.0',
Host => 'www.mydomain.com',
Connection => 'Keep-Alive',
Content => [
mykey => 'myValue', #some other key/value pair
cool_sounds => [undef, #file upload key/value pair
'myfile.wav',
'Content-Type' => 'audio/x-wav',
'Content-Disposition' => 'file',
Content => $rawdata
]
];
say $requ->as_string;
--output:--
POST http://thehost.com
Connection: Keep-Alive
Accept-Encoding: wav
Accept-Language: en-us
Host: www.mydomain.com
Referer: hxxp://www.mydomain.com/some.php3
User-Agent: Mozilla/4.0
Content-Length: 155
Content-Type: multipart/form-data; boundary=xYzZY
--xYzZY
Content-Disposition: form-data; name="mykey"
myValue
--xYzZY
Content-Disposition: file
Content-Type: audio/x-wav
hello world
--xYzZY--
この場合、ファイルセクションの名前属性はありません。
ところで、use statements
を投稿していないと助けてくれたと思いますか?それをしないでください。
http://stackoverflow.com/questions/21273071/how-does-rfc-2854-obsolete-rfc-1867は読む価値があります – Quentin
これは役に立たないと思います。 RFC1867のアップロード –