PHP Curl Request Class, Initiating Proper Variables for Request Type? First Time OOPPHP Simple OOP ClassTimer class in PHP OOPCritique Request: PHP Request-Method ClassProper usage of OOP PHPPHP OOP Login ClassContent management system for mediaRequest class in PHPPHP Response WrapperPHP OOP API ClassPHP HTTP request class

How does one intimidate enemies without having the capacity for violence?

Why do I get two different answers for this counting problem?

When a company launches a new product do they "come out" with a new product or do they "come up" with a new product?

What is the word for reserving something for yourself before others do?

Are the number of citations and number of published articles the most important criteria for a tenure promotion?

Unable to deploy metadata from Partner Developer scratch org because of extra fields

How can bays and straits be determined in a procedurally generated map?

What doth I be?

Horror movie about a virus at the prom; beginning and end are stylized as a cartoon

Revoked SSL certificate

Add text to same line using sed

Rock identification in KY

Can a vampire attack twice with their claws using Multiattack?

What's that red-plus icon near a text?

What defenses are there against being summoned by the Gate spell?

Why can't we play rap on piano?

Does an object always see its latest internal state irrespective of thread?

DC-DC converter from low voltage at high current, to high voltage at low current

Can a Cauchy sequence converge for one metric while not converging for another?

Do I have a twin with permutated remainders?

Modeling an IP Address

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

Languages that we cannot (dis)prove to be Context-Free

Can you really stack all of this on an Opportunity Attack?



PHP Curl Request Class, Initiating Proper Variables for Request Type? First Time OOP


PHP Simple OOP ClassTimer class in PHP OOPCritique Request: PHP Request-Method ClassProper usage of OOP PHPPHP OOP Login ClassContent management system for mediaRequest class in PHPPHP Response WrapperPHP OOP API ClassPHP HTTP request class






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0












$begingroup$


First time creating and constructing a PHP Object Class from scratch/near-scratch. Currently not using any pre-built class frameworks (although highly considering using an already constructed class like php-curl-class as a composer dependency down the line).



<?php

// Define Constants, etc.

require_once '../includeclass.php';

class Curl


const cookieJar = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';

public function get($url, $proxy = NULL)

$this->curl = curl_init($url);
$this->proxy = $proxy;
$this->setup($this->proxy);
return $this->request();


public function setup($proxy)

$this->headers = array();
$this->truncateCookie();

// Gets Random UserAgent (not included in post/review)
$this->ua = $this->getUA();
if ($proxy !== NULL)

$this->proxy = explode(':', $proxy) [0];
$this->proxyport = explode(':', $proxy) [1];
curl_setopt($this->curl, CURLOPT_PROXY, $this->proxy);
curl_setopt($this->curl, CURLOPT_PROXYPORT, $this->proxyport);


curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($this->curl, CURLOPT_TIMEOUT, 300);
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($this->curl, CURLOPT_ENCODING, 1);
curl_setopt($this->curl, CURLOPT_COOKIESESSION, 1);
curl_setopt($this->curl, CURLOPT_COOKIEJAR, self::cookieJar);
curl_setopt($this->curl, CURLOPT_COOKIEFILE, self::cookieJar);
curl_setopt($this->curl, CURLOPT_USERAGENT, $this->ua);
curl_setopt($this->curl, CURLOPT_HTTPHEADER, array(
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept-Language:en-US,en;q=0.9',
'Cache-Control: max-age=0',
'Connection: keep-alive',
'Host: example.com'
));
curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array(
$this,
'headerCallback'
));


public function truncateCookie()

$cookie = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';
$opencookiefile = @fopen($cookie, "r+");
if ($opencookiefile !== false)

ftruncate($opencookiefile, 0);
fclose($opencookiefile);



public function headerCallback($curl, $header)

$this->headers[] = $header;
$len = strlen($header);
$header = explode(':', $header, 2);
if (count($header) < 2) return $len;
$name = strtolower(trim($header[0]));
if (!array_key_exists($name, $this->headers)) $this->headers[$name] = [trim($header[1]) ];
else $this->headers[$name][] = trim($header[1]);
return $len;


public function request()

$this->curldata = curl_exec($this->curl);
$curlinfo = curl_getinfo($this->curl);
$respTime = $curlinfo['connect_time'];
$httpcode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);

// Condition to Ensure curldata returns HTML
if (preg_match("//[a-z]*>/i", $this->curldata) != 0)
// Condition to match download_size vs downloaded_size to ensure curl completed
// entire request in full (only applicable on some URLs that do
// not have any encoding in headers and actually show the
// content-length in retrieved headers/headers array
if (isset($this->headers['content-length'][0]))

$download_size = (int)$this->headers['content-length'][0];
$downloaded_size = strlen($this->curldata);
if ($httpcode === 200 && $download_size === $downloaded_size)

curl_close($this->curl);
return $this->curldata;



if ($httpcode === 200)

curl_close($this->curl);
return $this->curldata;



echo "rnrn" . "Failed: " . curl_errno($this->curl) . "rnrn";
curl_close($this->curl);
return false;


// Extra I'm including, not shown in example below
// Recursive Loop to Retry Curl Request until a Valid Response
// (still need to modify to create a max attempts condition..)

public function curlLoop(curl $curl, $url)

$count = 0;
while (true)

$count++;
echo "rnrn#" . $count . ": " . $url . "rnrn";
outputFlush();
$html = $curl->get($url);
if ($html !== false)

break;



return $html;


// end Class



And I'm using it like such (only thing functions shown doesn't hit on is my curlLoop function, which I included just for fun mostly (still needs to work, so not particularly relevant for Review):



$curl = new Curl();
$resp = $curl->get($url, $proxy);
if ($resp === FALSE)
//curl response failed
return false;

else {
// do whatever, successful curl response --- $resp = $this->curldata


Happy with this so far, the code works as shown.
Couple of setbacks/issues I'm having, major point being (and question in point from title), how would I best manage/account for the myriad of different URLs being passed through?



As discussed in my comments in the class, some conditions are only applicable to certain URLs.



As of right now, my Class is unsupported if the content-length header is shown and the curl response has encoded request headers (which makes strlen($this->curldata); a few kb bit less than what the headers display).
I want this here, as it has saved me a few times where the curl response was 200 but the request for some reason failed/did not download entirely.



Additionally, I'm a bit perplexed on how to add conditions for the proper headers. As you can see, the headers are hardwired to the url example.com for all requests. This is of course a big issue as headers should be appropriated to certain URLs.



Lastly, the blanket public statement for all methods in the class is an obvious issue. I still need to go over method visibilities and do some testing, so comment on this or not.



Any reviews/comments very much appreciated.. mostly learning as I go so progress can be a bit rocky at times.










share|improve this question









$endgroup$


















    0












    $begingroup$


    First time creating and constructing a PHP Object Class from scratch/near-scratch. Currently not using any pre-built class frameworks (although highly considering using an already constructed class like php-curl-class as a composer dependency down the line).



    <?php

    // Define Constants, etc.

    require_once '../includeclass.php';

    class Curl


    const cookieJar = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';

    public function get($url, $proxy = NULL)

    $this->curl = curl_init($url);
    $this->proxy = $proxy;
    $this->setup($this->proxy);
    return $this->request();


    public function setup($proxy)

    $this->headers = array();
    $this->truncateCookie();

    // Gets Random UserAgent (not included in post/review)
    $this->ua = $this->getUA();
    if ($proxy !== NULL)

    $this->proxy = explode(':', $proxy) [0];
    $this->proxyport = explode(':', $proxy) [1];
    curl_setopt($this->curl, CURLOPT_PROXY, $this->proxy);
    curl_setopt($this->curl, CURLOPT_PROXYPORT, $this->proxyport);


    curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 60);
    curl_setopt($this->curl, CURLOPT_TIMEOUT, 300);
    curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($this->curl, CURLOPT_ENCODING, 1);
    curl_setopt($this->curl, CURLOPT_COOKIESESSION, 1);
    curl_setopt($this->curl, CURLOPT_COOKIEJAR, self::cookieJar);
    curl_setopt($this->curl, CURLOPT_COOKIEFILE, self::cookieJar);
    curl_setopt($this->curl, CURLOPT_USERAGENT, $this->ua);
    curl_setopt($this->curl, CURLOPT_HTTPHEADER, array(
    'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
    'Accept-Language:en-US,en;q=0.9',
    'Cache-Control: max-age=0',
    'Connection: keep-alive',
    'Host: example.com'
    ));
    curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array(
    $this,
    'headerCallback'
    ));


    public function truncateCookie()

    $cookie = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';
    $opencookiefile = @fopen($cookie, "r+");
    if ($opencookiefile !== false)

    ftruncate($opencookiefile, 0);
    fclose($opencookiefile);



    public function headerCallback($curl, $header)

    $this->headers[] = $header;
    $len = strlen($header);
    $header = explode(':', $header, 2);
    if (count($header) < 2) return $len;
    $name = strtolower(trim($header[0]));
    if (!array_key_exists($name, $this->headers)) $this->headers[$name] = [trim($header[1]) ];
    else $this->headers[$name][] = trim($header[1]);
    return $len;


    public function request()

    $this->curldata = curl_exec($this->curl);
    $curlinfo = curl_getinfo($this->curl);
    $respTime = $curlinfo['connect_time'];
    $httpcode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);

    // Condition to Ensure curldata returns HTML
    if (preg_match("//[a-z]*>/i", $this->curldata) != 0)
    // Condition to match download_size vs downloaded_size to ensure curl completed
    // entire request in full (only applicable on some URLs that do
    // not have any encoding in headers and actually show the
    // content-length in retrieved headers/headers array
    if (isset($this->headers['content-length'][0]))

    $download_size = (int)$this->headers['content-length'][0];
    $downloaded_size = strlen($this->curldata);
    if ($httpcode === 200 && $download_size === $downloaded_size)

    curl_close($this->curl);
    return $this->curldata;



    if ($httpcode === 200)

    curl_close($this->curl);
    return $this->curldata;



    echo "rnrn" . "Failed: " . curl_errno($this->curl) . "rnrn";
    curl_close($this->curl);
    return false;


    // Extra I'm including, not shown in example below
    // Recursive Loop to Retry Curl Request until a Valid Response
    // (still need to modify to create a max attempts condition..)

    public function curlLoop(curl $curl, $url)

    $count = 0;
    while (true)

    $count++;
    echo "rnrn#" . $count . ": " . $url . "rnrn";
    outputFlush();
    $html = $curl->get($url);
    if ($html !== false)

    break;



    return $html;


    // end Class



    And I'm using it like such (only thing functions shown doesn't hit on is my curlLoop function, which I included just for fun mostly (still needs to work, so not particularly relevant for Review):



    $curl = new Curl();
    $resp = $curl->get($url, $proxy);
    if ($resp === FALSE)
    //curl response failed
    return false;

    else {
    // do whatever, successful curl response --- $resp = $this->curldata


    Happy with this so far, the code works as shown.
    Couple of setbacks/issues I'm having, major point being (and question in point from title), how would I best manage/account for the myriad of different URLs being passed through?



    As discussed in my comments in the class, some conditions are only applicable to certain URLs.



    As of right now, my Class is unsupported if the content-length header is shown and the curl response has encoded request headers (which makes strlen($this->curldata); a few kb bit less than what the headers display).
    I want this here, as it has saved me a few times where the curl response was 200 but the request for some reason failed/did not download entirely.



    Additionally, I'm a bit perplexed on how to add conditions for the proper headers. As you can see, the headers are hardwired to the url example.com for all requests. This is of course a big issue as headers should be appropriated to certain URLs.



    Lastly, the blanket public statement for all methods in the class is an obvious issue. I still need to go over method visibilities and do some testing, so comment on this or not.



    Any reviews/comments very much appreciated.. mostly learning as I go so progress can be a bit rocky at times.










    share|improve this question









    $endgroup$














      0












      0








      0





      $begingroup$


      First time creating and constructing a PHP Object Class from scratch/near-scratch. Currently not using any pre-built class frameworks (although highly considering using an already constructed class like php-curl-class as a composer dependency down the line).



      <?php

      // Define Constants, etc.

      require_once '../includeclass.php';

      class Curl


      const cookieJar = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';

      public function get($url, $proxy = NULL)

      $this->curl = curl_init($url);
      $this->proxy = $proxy;
      $this->setup($this->proxy);
      return $this->request();


      public function setup($proxy)

      $this->headers = array();
      $this->truncateCookie();

      // Gets Random UserAgent (not included in post/review)
      $this->ua = $this->getUA();
      if ($proxy !== NULL)

      $this->proxy = explode(':', $proxy) [0];
      $this->proxyport = explode(':', $proxy) [1];
      curl_setopt($this->curl, CURLOPT_PROXY, $this->proxy);
      curl_setopt($this->curl, CURLOPT_PROXYPORT, $this->proxyport);


      curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 60);
      curl_setopt($this->curl, CURLOPT_TIMEOUT, 300);
      curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
      curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false);
      curl_setopt($this->curl, CURLOPT_ENCODING, 1);
      curl_setopt($this->curl, CURLOPT_COOKIESESSION, 1);
      curl_setopt($this->curl, CURLOPT_COOKIEJAR, self::cookieJar);
      curl_setopt($this->curl, CURLOPT_COOKIEFILE, self::cookieJar);
      curl_setopt($this->curl, CURLOPT_USERAGENT, $this->ua);
      curl_setopt($this->curl, CURLOPT_HTTPHEADER, array(
      'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
      'Accept-Language:en-US,en;q=0.9',
      'Cache-Control: max-age=0',
      'Connection: keep-alive',
      'Host: example.com'
      ));
      curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array(
      $this,
      'headerCallback'
      ));


      public function truncateCookie()

      $cookie = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';
      $opencookiefile = @fopen($cookie, "r+");
      if ($opencookiefile !== false)

      ftruncate($opencookiefile, 0);
      fclose($opencookiefile);



      public function headerCallback($curl, $header)

      $this->headers[] = $header;
      $len = strlen($header);
      $header = explode(':', $header, 2);
      if (count($header) < 2) return $len;
      $name = strtolower(trim($header[0]));
      if (!array_key_exists($name, $this->headers)) $this->headers[$name] = [trim($header[1]) ];
      else $this->headers[$name][] = trim($header[1]);
      return $len;


      public function request()

      $this->curldata = curl_exec($this->curl);
      $curlinfo = curl_getinfo($this->curl);
      $respTime = $curlinfo['connect_time'];
      $httpcode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);

      // Condition to Ensure curldata returns HTML
      if (preg_match("//[a-z]*>/i", $this->curldata) != 0)
      // Condition to match download_size vs downloaded_size to ensure curl completed
      // entire request in full (only applicable on some URLs that do
      // not have any encoding in headers and actually show the
      // content-length in retrieved headers/headers array
      if (isset($this->headers['content-length'][0]))

      $download_size = (int)$this->headers['content-length'][0];
      $downloaded_size = strlen($this->curldata);
      if ($httpcode === 200 && $download_size === $downloaded_size)

      curl_close($this->curl);
      return $this->curldata;



      if ($httpcode === 200)

      curl_close($this->curl);
      return $this->curldata;



      echo "rnrn" . "Failed: " . curl_errno($this->curl) . "rnrn";
      curl_close($this->curl);
      return false;


      // Extra I'm including, not shown in example below
      // Recursive Loop to Retry Curl Request until a Valid Response
      // (still need to modify to create a max attempts condition..)

      public function curlLoop(curl $curl, $url)

      $count = 0;
      while (true)

      $count++;
      echo "rnrn#" . $count . ": " . $url . "rnrn";
      outputFlush();
      $html = $curl->get($url);
      if ($html !== false)

      break;



      return $html;


      // end Class



      And I'm using it like such (only thing functions shown doesn't hit on is my curlLoop function, which I included just for fun mostly (still needs to work, so not particularly relevant for Review):



      $curl = new Curl();
      $resp = $curl->get($url, $proxy);
      if ($resp === FALSE)
      //curl response failed
      return false;

      else {
      // do whatever, successful curl response --- $resp = $this->curldata


      Happy with this so far, the code works as shown.
      Couple of setbacks/issues I'm having, major point being (and question in point from title), how would I best manage/account for the myriad of different URLs being passed through?



      As discussed in my comments in the class, some conditions are only applicable to certain URLs.



      As of right now, my Class is unsupported if the content-length header is shown and the curl response has encoded request headers (which makes strlen($this->curldata); a few kb bit less than what the headers display).
      I want this here, as it has saved me a few times where the curl response was 200 but the request for some reason failed/did not download entirely.



      Additionally, I'm a bit perplexed on how to add conditions for the proper headers. As you can see, the headers are hardwired to the url example.com for all requests. This is of course a big issue as headers should be appropriated to certain URLs.



      Lastly, the blanket public statement for all methods in the class is an obvious issue. I still need to go over method visibilities and do some testing, so comment on this or not.



      Any reviews/comments very much appreciated.. mostly learning as I go so progress can be a bit rocky at times.










      share|improve this question









      $endgroup$




      First time creating and constructing a PHP Object Class from scratch/near-scratch. Currently not using any pre-built class frameworks (although highly considering using an already constructed class like php-curl-class as a composer dependency down the line).



      <?php

      // Define Constants, etc.

      require_once '../includeclass.php';

      class Curl


      const cookieJar = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';

      public function get($url, $proxy = NULL)

      $this->curl = curl_init($url);
      $this->proxy = $proxy;
      $this->setup($this->proxy);
      return $this->request();


      public function setup($proxy)

      $this->headers = array();
      $this->truncateCookie();

      // Gets Random UserAgent (not included in post/review)
      $this->ua = $this->getUA();
      if ($proxy !== NULL)

      $this->proxy = explode(':', $proxy) [0];
      $this->proxyport = explode(':', $proxy) [1];
      curl_setopt($this->curl, CURLOPT_PROXY, $this->proxy);
      curl_setopt($this->curl, CURLOPT_PROXYPORT, $this->proxyport);


      curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 60);
      curl_setopt($this->curl, CURLOPT_TIMEOUT, 300);
      curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
      curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false);
      curl_setopt($this->curl, CURLOPT_ENCODING, 1);
      curl_setopt($this->curl, CURLOPT_COOKIESESSION, 1);
      curl_setopt($this->curl, CURLOPT_COOKIEJAR, self::cookieJar);
      curl_setopt($this->curl, CURLOPT_COOKIEFILE, self::cookieJar);
      curl_setopt($this->curl, CURLOPT_USERAGENT, $this->ua);
      curl_setopt($this->curl, CURLOPT_HTTPHEADER, array(
      'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
      'Accept-Language:en-US,en;q=0.9',
      'Cache-Control: max-age=0',
      'Connection: keep-alive',
      'Host: example.com'
      ));
      curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array(
      $this,
      'headerCallback'
      ));


      public function truncateCookie()

      $cookie = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';
      $opencookiefile = @fopen($cookie, "r+");
      if ($opencookiefile !== false)

      ftruncate($opencookiefile, 0);
      fclose($opencookiefile);



      public function headerCallback($curl, $header)

      $this->headers[] = $header;
      $len = strlen($header);
      $header = explode(':', $header, 2);
      if (count($header) < 2) return $len;
      $name = strtolower(trim($header[0]));
      if (!array_key_exists($name, $this->headers)) $this->headers[$name] = [trim($header[1]) ];
      else $this->headers[$name][] = trim($header[1]);
      return $len;


      public function request()

      $this->curldata = curl_exec($this->curl);
      $curlinfo = curl_getinfo($this->curl);
      $respTime = $curlinfo['connect_time'];
      $httpcode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);

      // Condition to Ensure curldata returns HTML
      if (preg_match("//[a-z]*>/i", $this->curldata) != 0)
      // Condition to match download_size vs downloaded_size to ensure curl completed
      // entire request in full (only applicable on some URLs that do
      // not have any encoding in headers and actually show the
      // content-length in retrieved headers/headers array
      if (isset($this->headers['content-length'][0]))

      $download_size = (int)$this->headers['content-length'][0];
      $downloaded_size = strlen($this->curldata);
      if ($httpcode === 200 && $download_size === $downloaded_size)

      curl_close($this->curl);
      return $this->curldata;



      if ($httpcode === 200)

      curl_close($this->curl);
      return $this->curldata;



      echo "rnrn" . "Failed: " . curl_errno($this->curl) . "rnrn";
      curl_close($this->curl);
      return false;


      // Extra I'm including, not shown in example below
      // Recursive Loop to Retry Curl Request until a Valid Response
      // (still need to modify to create a max attempts condition..)

      public function curlLoop(curl $curl, $url)

      $count = 0;
      while (true)

      $count++;
      echo "rnrn#" . $count . ": " . $url . "rnrn";
      outputFlush();
      $html = $curl->get($url);
      if ($html !== false)

      break;



      return $html;


      // end Class



      And I'm using it like such (only thing functions shown doesn't hit on is my curlLoop function, which I included just for fun mostly (still needs to work, so not particularly relevant for Review):



      $curl = new Curl();
      $resp = $curl->get($url, $proxy);
      if ($resp === FALSE)
      //curl response failed
      return false;

      else {
      // do whatever, successful curl response --- $resp = $this->curldata


      Happy with this so far, the code works as shown.
      Couple of setbacks/issues I'm having, major point being (and question in point from title), how would I best manage/account for the myriad of different URLs being passed through?



      As discussed in my comments in the class, some conditions are only applicable to certain URLs.



      As of right now, my Class is unsupported if the content-length header is shown and the curl response has encoded request headers (which makes strlen($this->curldata); a few kb bit less than what the headers display).
      I want this here, as it has saved me a few times where the curl response was 200 but the request for some reason failed/did not download entirely.



      Additionally, I'm a bit perplexed on how to add conditions for the proper headers. As you can see, the headers are hardwired to the url example.com for all requests. This is of course a big issue as headers should be appropriated to certain URLs.



      Lastly, the blanket public statement for all methods in the class is an obvious issue. I still need to go over method visibilities and do some testing, so comment on this or not.



      Any reviews/comments very much appreciated.. mostly learning as I go so progress can be a bit rocky at times.







      php object-oriented curl






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 14 mins ago









      Brian BrumanBrian Bruman

      1134




      1134




















          0






          active

          oldest

          votes












          Your Answer





          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216959%2fphp-curl-request-class-initiating-proper-variables-for-request-type-first-time%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216959%2fphp-curl-request-class-initiating-proper-variables-for-request-type-first-time%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

          Prove that NP is closed under karp reduction?Space(n) not closed under Karp reductions - what about NTime(n)?Class P is closed under rotation?Prove or disprove that $NL$ is closed under polynomial many-one reductions$mathbfNC_2$ is closed under log-space reductionOn Karp reductionwhen can I know if a class (complexity) is closed under reduction (cook/karp)Check if class $PSPACE$ is closed under polyonomially space reductionIs NPSPACE also closed under polynomial-time reduction and under log-space reduction?Prove PSPACE is closed under complement?Prove PSPACE is closed under union?

          Is my guitar’s action too high? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strings too stiff on a recently purchased acoustic guitar | Cort AD880CEIs the action of my guitar really high?Μy little finger is too weak to play guitarWith guitar, how long should I give my fingers to strengthen / callous?When playing a fret the guitar sounds mutedPlaying (Barre) chords up the guitar neckI think my guitar strings are wound too tight and I can't play barre chordsF barre chord on an SG guitarHow to find to the right strings of a barre chord by feel?High action on higher fret on my steel acoustic guitar