cURL / Mailing Lists / curl-library / Single Mail

curl-library

Inconsistent text case using CURLINFO_EFFECTIVE_URL

From: <mtroispont_at_hush.com>
Date: Tue, 13 May 2014 09:47:22 +0200

Hello,

// Problem

CURLINFO_EFFECTIVE_URL either begins with "http://" (uppercase) or "http://" (lowercase).

source → CURLINFO_EFFECTIVE_URL

pouet.net → http://www.pouet.net/
www.pouet.net → http://www.pouet.net

lemonde.fr → http://www.lemonde.fr/
www.lemonde.fr → http://www.lemonde.fr

pastebin.com → http://pastebin.com
www.pastebin.com → http://pastebin.com/

curl.haxx.se → http://curl.haxx.se
www.curl.haxx.se → http://www.curl.haxx.se

google.com → http://www.google.fr/?gws_rd=cr&ei=tracking_junk
www.google.com → http://www.google.fr/?gfe_rd=cr&ei=tracking_junk

// Affected product

Tested on libcurl 7.26.0 (used with PHP).

// Expected behavior

Lowercase every time.

// How to reproduce the bug

Copy/paste this piece of code in a file, from the CLI, run:

$ php file

(syntax highlighting: http://pastebin.com/AeYSh0Aj )

<?php

$urls = array(
  'pouet.net',
  'www.pouet.net',
  'lemonde.fr',
  'www.lemonde.fr',
  'pastebin.com',
  'www.pastebin.com',
  'curl.haxx.se',
  'www.curl.haxx.se',
  'google.com',
  'www.google.com'
);

foreach ($urls as $source) {
  $req = curl_init();

  $options = array(
    CURLOPT_FAILONERROR => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HEADER => true,
    CURLOPT_NOBODY => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_URL => $source,
  );

  curl_setopt_array($req, $options);

  if ($res = curl_exec($req)) {
    echo $source . ' → ' . curl_getinfo($req, CURLINFO_EFFECTIVE_URL);

    curl_close($req);
  } else {
    echo $source . ' → ' . 'failed';
  }

  echo "\n\n";
}

Thanks for your help,

Marc

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-05-13