Permalink
Browse files

Enabled SSL by default in cli script. Updated UA Browser headers.

  • Loading branch information...
zaf committed Oct 22, 2012
1 parent 69063dd commit bb496127c486cefd67a5d41e300ab7fb15565d1c
Showing with 7 additions and 15 deletions.
  1. +6 −14 samples/speech-recog-cli.pl
  2. +1 −1 speech-recog.agi
@@ -30,22 +30,23 @@
my $filetype;
my $audio;
my $ua;
-my $url;
-my $host = "www.google.com/speech-api/v1/recognize";
+my $url = "https://www.google.com/speech-api/v1/recognize";
my $samplerate = 8000;
my $language = "en-US";
my $output = "detailed";
my $results = 1;
my $pro_filter = 0;
my $error = 0;
-getopts('l:o:r:n:fshq', \%options);
+getopts('l:o:r:n:fhq', \%options);
VERSION_MESSAGE() if (defined $options{h} || !@ARGV);
parse_options();
-$ua->agent("Mozilla/5.0 (X11; Linux) AppleWebKit/535.2 (KHTML, like Gecko)");
+
+$ua = LWP::UserAgent->new(ssl_opts => {verify_hostname => 1});
+$ua->agent("Mozilla/5.0 (X11; Linux) AppleWebKit/537.1 (KHTML, like Gecko)");
$ua->env_proxy;
$ua->conn_cache(LWP::ConnCache->new());
$ua->timeout(20);
@@ -69,7 +70,7 @@
next;
}
}
- print("Openning $file\n") if (!defined $options{q});
+ print("Openning $filename\n") if (!defined $options{q});
if (open(my $fh, "<", "$file")) {
$audio = do { local $/; <$fh> };
close($fh);
@@ -146,14 +147,6 @@ sub parse_options {
# set audio sampling rate #
$samplerate = $options{r} if ($options{r} =~ /\d+/);
}
- if (defined $options{s}) {
- # Set up connection type #
- $url = "https://" . $host;
- $ua = LWP::UserAgent->new(ssl_opts => {verify_hostname => 1});
- } else {
- $url = "http://" . $host;
- $ua = LWP::UserAgent->new;
- }
# set profanity filter #
$pro_filter = 2 if (defined $options{f});
@@ -205,7 +198,6 @@ sub VERSION_MESSAGE {
" -r <rate> specify the audio sample rate in Hz (deafult 8000)\n",
" -n <number> specify the maximum number of results (default 1)\n",
" -f filter out profanities\n",
- " -s use SSL to encrypt web trafic\n",
" -q don't print any error messages or warnings\n",
" -h this help message\n\n";
exit(1);
View
@@ -205,7 +205,7 @@ if ($use_ssl) {
$language = escape($language);
$grammar = escape($grammar);
$url .= "?xjerr=1&client=chromium&lang=$language&pfilter=$pro_filter&lm=$grammar&maxresults=$results";
-$ua->agent("Mozilla/5.0 (X11; Linux) AppleWebKit/535.2 (KHTML, like Gecko)");
+$ua->agent("Mozilla/5.0 (X11; Linux) AppleWebKit/537.1 (KHTML, like Gecko)");
$ua->env_proxy;
$ua->timeout($ua_timeout);

0 comments on commit bb49612

Please sign in to comment.