if ($next_try_at < time) {
$retry_msg = "Retrying.";
} else {
- my $next_try_fmt = strftime("%Y-%m-%d %H:%M:%S", $next_try_at);
+ my $next_try_fmt = strftime("%Y-%m-%d %H:%M:%S", localtime($next_try_at));
$retry_msg = "Retrying at $next_try_fmt.";
}
Log(undef, "API method $method_name failed: $errmsg. $retry_msg");
my $content;
while (($p, $v) = each %content) {
$content .= '&' unless $content eq '';
- $content .= uri_escape($p);
+ $content .= lean_uri_escape($p);
$content .= '=';
- $content .= uri_escape($v);
+ $content .= lean_uri_escape($v);
}
$self->{'req'}->content_type("application/x-www-form-urlencoded; charset='utf8'");
$self->{'req'}->content(Encode::encode('utf8', $content));
""
}
+# lean_uri_escape consumes about half as much memory
+# as URI::Escape::uri_escape.
+sub lean_uri_escape {
+ my ($text) = @_;
+ $text =~ s/([^A-Za-z0-9\-\._~])/$URI::Escape::escapes{$&}/ge;
+ return $text;
+}
+
1;