title: Jsoup malformed url
body: <p>I'm having trouble with connecting to a url with JSoup.</p>
  
  <p>The url I am trying to test is www.xbox.com/en-US/security which is a 302(I think) redirect to  <a href="http://www.xbox.com/en-US/Live/Account-Security" rel="nofollow">http://www.xbox.com/en-US/Live/Account-Security</a>. I have set up jsoup to follow redirect and get the new url using .headers("location"). The url returned is /en-US/Live/Account-Security. I'm not sure how to handle it, my code is below:</p>
  
  <pre><code>while (i &lt; retries){
          try {
              response = Jsoup.connect(checkUrl)
                      .userAgent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21")
                      .followRedirects(false)
                      .timeout(10000)
                      .execute();
              success = true;
              break;
          } catch (SocketTimeoutException ex){
              timeout = true;
          }  catch (MalformedURLException ep){
              malformedUrl = true;
          }catch (IOException e) {
              statusCode = 404;
          }
      }
  
  private void getStatus(){
      if (success){
          statusCode = response.statusCode();
          success = false;
      }
      if (statusCode &gt;= 300 &amp;&amp; statusCode &lt;= 399){
          //System.out.println("redirect: " +statusCode + " " +checkUrl);
          checkUrl = response.header("location");
          //System.out.println(checkUrl);
          connect();
          getStatus();
      }
  }
  </code></pre>
  
  <p>Has anyone got suggestions on how to handle this? Or should I do a check on my checkUrl = response.header("location"); to see if it is a valid url and if not don't test it?</p>