Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-49497

Not possible to set user-agent string with class curl

    XMLWordPrintable

    Details

      Description

      Given the following cli script:

      <?php
       
      define('CLI_SCRIPT', true);
      require_once(__DIR__.'/config.php');
      require_once($CFG->libdir.'/filelib.php');
      $curl = new curl();
      $curl->setopt(array('useragent' => 'Dan Test/1.0'));
      $curl->get('http://google.com/test');
      

      And doing a a tcpdump to see the packets whcih go out..

      sudo tcpdump -s 1024 -l -A host google.com
      [..]
      GET /test HTTP/1.1
      Host: google.com
      Accept: */*
      Accept-Encoding: deflate, gzip
      User-Agent: MoodleBot/1.0
      Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
      Connection: keep-alive
      

      You see that the useragent string always gets set to Moodlebot/1.0 and doesn't take my useragent string. (I am dealing with an API which requests you set the useragent string to something sepcific)

        Attachments

          Activity

            People

            Assignee:
            davecooper Dave Cooper
            Reporter:
            poltawski Dan Poltawski
            Peer reviewer:
            Neill Magill
            Integrator:
            Dan Poltawski
            Tester:
            CiBoT
            Participants:
            Component watchers:
            Matteo Scaramuccia, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              6/Jul/15