Plugin Directory

Changeset 1446383


Ignore:
Timestamp:
06/30/2016 09:28:11 AM (10 years ago)
Author:
ishaijaffe
Message:

buffer large requests

Location:
bablic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • bablic/tags/2.1/sdk.php

    r1432220 r1446383  
    6666    private $version = '';
    6767    private $meta = '';
     68    private $_body = '';
     69    private $pos = 0;
    6870
    6971    function __construct($options) {
     
    489491    }
    490492
     493    public function write_buffer($ch,$fp,$len){     
     494        $data = substr($this->_body, $this->pos, $len);
     495        // increment $pos
     496        $this->pos += strlen($data);
     497        // return the data to send in the request
     498        return $data;
     499    }
     500   
    491501    private function send_to_bablic($url, $html) {
    492502        $bablic_url = "http://seo.bablic.com/api/engine/seo?site=$this->site_id&url=".urlencode($url).($this->subdir ? "&ld=subdir" : "");
    493503        $curl = curl_init($bablic_url);
    494 
     504        $length = strlen($html);
    495505        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    496506        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    497507        curl_setopt($curl, CURLOPT_HEADER, false);
    498508        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    499         curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: text/html","Expect:"));
     509        curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: text/html", "Content-Length: $length","Expect:"));
    500510        curl_setopt($curl, CURLOPT_POST, true);
    501         curl_setopt($curl, CURLOPT_POSTFIELDS, $html);
     511        $this->_body = $html;
     512        $this->pos = 0;
     513        curl_setopt($curl, CURLOPT_READFUNCTION, array(&$this,'write_buffer'));
    502514       
    503515        $response = curl_exec($curl);
  • bablic/trunk/sdk.php

    r1432220 r1446383  
    6666    private $version = '';
    6767    private $meta = '';
     68    private $_body = '';
     69    private $pos = 0;
    6870
    6971    function __construct($options) {
     
    489491    }
    490492
     493    public function write_buffer($ch,$fp,$len){     
     494        $data = substr($this->_body, $this->pos, $len);
     495        // increment $pos
     496        $this->pos += strlen($data);
     497        // return the data to send in the request
     498        return $data;
     499    }
     500   
    491501    private function send_to_bablic($url, $html) {
    492502        $bablic_url = "http://seo.bablic.com/api/engine/seo?site=$this->site_id&url=".urlencode($url).($this->subdir ? "&ld=subdir" : "");
    493503        $curl = curl_init($bablic_url);
    494 
     504        $length = strlen($html);
    495505        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    496506        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    497507        curl_setopt($curl, CURLOPT_HEADER, false);
    498508        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    499         curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: text/html","Expect:"));
     509        curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: text/html", "Content-Length: $length","Expect:"));
    500510        curl_setopt($curl, CURLOPT_POST, true);
    501         curl_setopt($curl, CURLOPT_POSTFIELDS, $html);
     511        $this->_body = $html;
     512        $this->pos = 0;
     513        curl_setopt($curl, CURLOPT_READFUNCTION, array(&$this,'write_buffer'));
    502514       
    503515        $response = curl_exec($curl);
Note: See TracChangeset for help on using the changeset viewer.