Skip to content

Instantly share code, notes, and snippets.

@yko
Created June 19, 2010 07:14
Show Gist options
  • Save yko/444660 to your computer and use it in GitHub Desktop.
Save yko/444660 to your computer and use it in GitHub Desktop.
sub build_tx {
my ($self, $user, $pass) = @_;
croak("Basic authorization user name can't contain ':'")
if $user =~ /:/;
# or build_tx('POST|GET|...', ...), see Mojo::Client
my ($tx, $cb) = $self->client->build_form_tx($url, {
field => 'value',
# ...
});
$tx->req->headers->header(
Authorization => 'Basic ' . b($self->user . ':' . $self->pass)->b64_encode
);
return $tx;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment