title: How may I bypass LWP's URL encoding for a GET request?
body: <p>I'm talking to what seems to be a broken HTTP daemon and I need to make a <code>GET</code> request that includes a pipe <code>|</code> character in the URL.</p>
  
  <p><a href="https://metacpan.org/module/LWP%3a%3aUserAgent" rel="nofollow"><code>LWP::UserAgent</code></a> escapes the pipe character before the request is sent.</p>
  
  <p>For example, a URL passed in as:</p>
  
  <pre><code>https://hostname/url/doSomethingScript?ss=1234&amp;activities=Lec1|01
  </code></pre>
  
  <p>is passed to the HTTP daemon as</p>
  
  <pre><code>https://hostname/url/doSomethingScript?ss=1234&amp;activities=Lec1%7C01
  </code></pre>
  
  <p>This is correct, but doesn't work with this broken server.</p>
  
  <p>How can I override or bypass the encoding that LWP and its friends are doing?</p>
  
  <p><strong>Note</strong></p>
  
  <p>I've seen and tried other answers here on StackOverflow addressing similar problems. The difference here seems to be that those answers are dealing with <code>POST</code> requests where the <code>formfield</code> parts of the URL can be passed as an array of key/value pairs or as a <code>'Content' =&gt; $content</code> parameter. Those approaches aren't working for me with an LWP request.</p>
  
  <p>I've also tried constructing an <code>HTTP::Request</code> object and passing that to LWP, and passing the full URL direct to <code>LWP-&gt;get()</code>. No dice with either approach.</p>
  
  <hr>
  
  <p>In response to Borodin's request,  this is a sanitised version of the code I'm using</p>
  
  <pre><code>#!/usr/local/bin/perl -w
  use HTTP::Cookies;
  use LWP;
  
  my $debug = 1;
  
  # make a 'browser' object
  my $browser = LWP::UserAgent-&gt;new();
  
  # cookie handling...
  $browser-&gt;cookie_jar(HTTP::Cookies-&gt;new(
               'file' =&gt; '.cookie_jar.txt',
               'autosave' =&gt; 1,
               'ignore_discard' =&gt; 1,
               ));
  
  # proxy, so we can watch...
  if ($debug == 1) {
      $browser-&gt;proxy(['http', 'ftp', 'https'], 'http://localhost:8080/');
  }
  
  # user agent string (pretend to be Firefox)
  $agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.7.12) Gecko/20050919 Firefox/1.0.7';
  
  # set the user agent
  $browser-&gt;agent($agent);
  
  # do some things here to log in to the web site, accept session cookies, etc. 
  # These are basic POSTs of filled forms. Works fine.
  # [...]
  
  my $baseURL = 'https://hostname/url/doSomethingScript?ss=1234&amp;activities=VALUEA|VALUEB';
  
  @values = ['Lec1', '01', 'Lec1', '02'];
  
  while (1) {
      if (scalar(@values) &lt; 2) { last; }
  
      my $vala = shift(@values);
      my $valb = shift(@values);
  
      my $url = $basEURL;
      $url =~ s/VALUEA/$vala/g;
      $url =~ s/VALUEB/$valb/g;
  
      # simplified. Would usually check request for '200' response, etc...
      $content = $browser-&gt;get($url)-&gt;content();
  
      # do something here with the content
  
      # [...]
  
      # fails because the '|' character in the url is escaped after it's handed 
      # to LWP
  
  }
  
  # end
  </code></pre>