Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timeout issue for post requests via get_url on OS X #622

Merged
merged 2 commits into from
Oct 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/get_url
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/perl
#!/usr/bin/env perl
# -*- Perl -*-

use strict;
Expand Down Expand Up @@ -103,7 +103,7 @@ sub use_ua {
$ua->proxy( [ 'http', 'ftp' ] => $config_parms{proxy} )
if $config_parms{proxy};

$ua->timeout( [120] ); # Time out after 60 seconds
$ua->timeout( 30 ); # Time out after 30 seconds
$ua->env_proxy();
$ua->agent( $config_parms{get_url_ua} ) if $config_parms{get_url_ua};

Expand Down
28 changes: 28 additions & 0 deletions code/test/test_mh.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
# At startup program a time to stop the test after one minute
my $shutdown_timer = new Timer; #noloop
$shutdown_timer->set(60, \&shutdown); #noloop
my $start_test_code_timer = new Timer; #noloop
$start_test_code_timer->set(5, \&start_tests); #noloop

# Test get_url with a post parameter
my $get_url_output = '/tmp/get_url_post.txt';
my $get_url_test = new Process_Item("get_url -post 'testparameter=1' http://httpbin.org/post $get_url_output");

if ($Startup) {
$shutdown_timer->start();
Expand All @@ -13,3 +19,25 @@ sub shutdown {
print_log "Stopping self-test, exit...";
run_voice_cmd("Exit Mister House");
}

sub start_tests {
print_log "Starting the test routines...";
## get_url with post parameter
unlink $get_url_output;
$get_url_test->start();
}

if ($get_url_test->done_now()) {
print_log "Get URL test done, checking output";
my $url_test = file_read($get_url_output);

if ($url_test =~ /testparameter/g) {
# Test passed fine
print_log "get_url code with post worked as expected";

} else {
# Test failed
print_log "get_url code with post failed, output was '$url_test'";
exit -1;
}
}