
Kanji
User
/ Moderator
Aug 25, 2001, 6:19 PM
Post #2 of 2
(7876 views)
|
1) How does a browser normally prepare to POST multiple select menus and / or multiple fields with the same name attribute (eg checkboxes), and how do I emulate this when preparing the data hash for the request object? Each value of same-name fields are reproduced in key=value fashion as if they were the only one, and then stringed together later on as you would for any other field you need to add either directly with HTTP::Request's new or content methods.
$req = HTTP::Request->new( POST => $url ); $req->content("field=value1&field=value2&ad=nauseum"); Personally, I find it much easier to use HTTP::Request::Common instead, and let it build my query strings for me.
$req = POST $url, [ "field" => "value1", "field" => "value2", "ad" => "nauseum", ]; 2) How do I prepare the headers for www_authenticate or authorization? There's a few ways, but the easist is probably using HTTP::Request's authorization_basic method.
$req->authorization_basic( "username", "password" ); Other alternatives include tacking on an Authorization header, using LWP::UserAgent's credentials method, or overriding LWP::UserAgent's get_basic_credentials; each of which have their pros and cons.
|