Commit 2e1ba24a authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Deal with a problem that surfaced on FreeBSD 9.0 and associated ports.

The problem is with the chunking that apache does to avoid having
to read the entire response, so it can set the Content-Length header
properly. I have no idea who apache does chunking, but on the 9.0
client it was getting confused and trash characters were leaking into
the data. The trash is probably the result of the client getting out
of sync. 

Anyway, I do not know who is at fault (client code or our ancient
apache server), but after many hours of screwing around I found out
how to prevent the client from getting chunked data from the server.

Basically, you have to force the request to be sent as HTTP/1.0
instead of 1.1, which tells apache to not chunk the data. In general
this is not a good thing to do, but in this case the RPCs are pretty
small and not on a critical performance path. We can revisit when we
upgrade our boss to apache 2.X ...
parent 8f500e1b
#!/usr/bin/perl -w
# Copyright (c) 2008-2011 University of Utah and the Flux Group.
# Copyright (c) 2008-2012 University of Utah and the Flux Group.
# All rights reserved.
# Perl code to access an XMLRPC server using http. Derived from the
......@@ -30,6 +30,17 @@ my $timeout = 500;
# Version of FreeBSD.
my $FBSD_MAJOR = 4;
my $FBSD_MINOR = 10;
if (`uname -r` =~ /^(\d+)\.(\d+)/) {
else {
die("Could not determine what version of FreeBSD you are running!\n");
# This is the "structure" returned by the RPC server. It gets converted into
# a perl hash by the unmarshaller, and we return that directly to the caller
......@@ -136,7 +147,6 @@ sub CallMethod($$$@)
my ($httpURL, $context, $method, @args) = @_;
require RPC::XML;
require RPC::XML::Parser;
require LWP::UserAgent;
require HTTP::Request::Common;
import HTTP::Request::Common;
require HTTP::Headers;
......@@ -152,12 +162,20 @@ sub CallMethod($$$@)
"Must provide an rpc context");
if (0) {
if ($FBSD_MAJOR >= 9) {
require LWP::UserAgent;
require IO::Socket::SSL;
require Net::HTTPS;
# Turn off silly check many levels down.
# This does not work. Not sure why, but need to figure it out
# cause it does cert chains while Crypt::SSL (below) does not.
$IO::Socket::SSL::DEBUG = 4;
#$IO::Socket::SSL::DEBUG = 4;
$Net::SSLeay::slowly = 1;
$IO::Socket::SSL::GLOBAL_CONTEXT_ARGS->{'SSL_key_file'} =
......@@ -176,6 +194,11 @@ sub CallMethod($$$@)
else {
require Net::SSL;
require Net::HTTPS;
require LWP::UserAgent;
# This is for the Crypt::SSL library, many levels down. It
# appears to be the only way to specify this. Even worse, when
......@@ -197,7 +220,7 @@ sub CallMethod($$$@)
print STDERR "xml request: $httpURL:" . $request->as_string();
print STDERR "\n";
# Send an http post.
......@@ -208,6 +231,7 @@ sub CallMethod($$$@)
my $hreq = HTTP::Request->new(POST => $httpURL);
$hreq->protocol('HTTP/1.0') if ($FBSD_MAJOR >= 9);
my $hresp = $ua->request($hreq);
# Do this or the next call gets messed up.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment