I've been working on some Perl libraries to handle most of the HTTP API functionality. What I noticed is that the HTTP API doesn't fully follow the HTTP 1.1 standard when it comes to importing maps with spaces in the mapname.

The typical behaviour with HTTP 1.1 compliant clients is that spaces are "escaped" so that they are replaced by their hex representation. A map called "My Map" will have to be pushed as "/~files/maps/My%20Map" amd will appear as such in the Map list. The HTTP API documentation suggests using Curl to import maps from command-line. When running Curl to upload that same map, with the following parameters, all seems to be working as well (suggesting Curl also does not follow the HTTP 1.1 standards):

curl.exe -v -k --user admin:password --data-binary @"My Map" "https://admin:password@INTERMAPPER/~files/maps/My Map"

A verbose output of the above returns the following lines:

...
* Server auth using Basic with user 'admin'
> POST /~files/maps/My Map HTTP/1.1
> Authorization: Basic xxxxxxxxxxxxxxxxxxxx
> User-Agent: curl/7.29.0
> Host: INTERMAPPER
> Accept: */*
> Content-Length: xxxxxx
> Content-Type: application/x-www-form-urlencoded
...
File xxxxxx-My Map successfully imported*

A similar approach with Perl's HTTP::Request returns the following:

POST https://admin:password@INTERMAPPER/~files/maps/My%20Map
Accept: */*
Content-Type: application/x-www-form-urlencoded
File xxxxxx-My%Map successfully imported

Typical Perl code for this would be:

use LWP::UserAgent;
use HTTP::Request;
# Load map data in $data here...
my $ua = LWP::UserAgent->new();
my $req = HTTP::Request->new(POST => "https://admin:password@INTERMAPPER/~files/maps/My Map");
$req->content_type("application/x-www-form-urlencoded");
$req->content($data);
$req->header("Accept" => "*/*");
my $res = $ua->request($req);

Does anyone else have any issues with this? Besides handcrafting HTTP requests (or using alternate web modules that aren't as picky as LWP::UA / HTTP::Request), are there any alternatives?

Submitted by hvanbelleghem