From afb4c93407474aba99c7fd50baff52f54a9d7a0c Mon Sep 17 00:00:00 2001
From: Zhicheng-Liu <zl@ebi.ac.uk>
Date: Mon, 12 Dec 2016 21:26:41 +0000
Subject: [PATCH] Escape space characters in the URLs for example requests

For some endpoints species alias that contains space charactter could
appear in the URI path. In some languages and tools, URLs are not
automatically encoded. The space characters in the URLs cause failure
in the requests.

This change escapes space characters in the URLs for the example requests
for Curl, Java, Perl and Ruby, according to this document:
http://template-toolkit.org/docs/manual/Filters.html#section_url

Fixes ENSEMBL-4809.
---
 root/documentation/examples/curl.tt | 4 ++--
 root/documentation/examples/java.tt | 2 +-
 root/documentation/examples/perl.tt | 4 ++--
 root/documentation/examples/ruby.tt | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/root/documentation/examples/curl.tt b/root/documentation/examples/curl.tt
index fb37f0eb..93597e92 100644
--- a/root/documentation/examples/curl.tt
+++ b/root/documentation/examples/curl.tt
@@ -18,10 +18,10 @@ limitations under the License.
 <div class='tab-pane' id='curl[% p.value.id %]'>
 <pre class="pre-scrollable prettyprint linenums">[% FILTER html %]
 [% IF p.value.body -%]
-curl '[% p.value.example.host %][% p.value.uri %]' -H 'Content-type:[% p.value.content %]' \
+curl '[% p.value.example.host %][% p.value.uri | url %]' -H 'Content-type:[% p.value.content %]' \
 -H 'Accept:[% p.value.accept %]' -X POST -d '[% p.value.body %]'
 [% ELSE %]
-curl '[% p.value.example.host %][% p.value.uri %]' -H 'Content-type:[% p.value.content %]'
+curl '[% p.value.example.host %][% p.value.uri | url %]' -H 'Content-type:[% p.value.content %]'
 [% END %]
 [% END -%]
 </pre>
diff --git a/root/documentation/examples/java.tt b/root/documentation/examples/java.tt
index 9357a2f9..b2433790 100644
--- a/root/documentation/examples/java.tt
+++ b/root/documentation/examples/java.tt
@@ -33,7 +33,7 @@ public class EnsemblRest {
 
   public static void main(String[] args) throws Exception {
     String server = "[% p.value.example.host %]";
-    String ext = "[% p.value.uri %]";
+    String ext = "[% p.value.uri | url %]";
     URL url = new URL(server + ext);
 
     URLConnection connection = url.openConnection();
diff --git a/root/documentation/examples/perl.tt b/root/documentation/examples/perl.tt
index 6b9f305d..ec5c8594 100644
--- a/root/documentation/examples/perl.tt
+++ b/root/documentation/examples/perl.tt
@@ -26,7 +26,7 @@ my $http = HTTP::Tiny->new();
 
 my $server = '[% p.value.example.host %]';
 [% IF p.value.body -%]
-my $ext = '[% p.value.uri %]';
+my $ext = '[% p.value.uri | url %]';
 my $response = $http->request('POST', $server.$ext, {
   headers => { 
   	'Content-type' => '[% p.value.content %]',
@@ -35,7 +35,7 @@ my $response = $http->request('POST', $server.$ext, {
   content => '[% p.value.body %]'
 });
 [% ELSE -%]
-my $ext = '[% p.value.uri %]';
+my $ext = '[% p.value.uri | url %]';
 my $response = $http->get($server.$ext, {
   headers => { 'Content-type' => '[% p.value.content %]' }
 });
diff --git a/root/documentation/examples/ruby.tt b/root/documentation/examples/ruby.tt
index f511f5a3..34581151 100644
--- a/root/documentation/examples/ruby.tt
+++ b/root/documentation/examples/ruby.tt
@@ -21,7 +21,7 @@ require 'net/http'
 require 'uri'
 
 server='[% p.value.example.host %]'
-path = '[% p.value.uri %]'
+path = '[% p.value.uri | url %]'
 
 url = URI.parse(server)
 http = Net::HTTP.new(url.host, url.port)
-- 
GitLab