Code Monkey home page Code Monkey logo

curl-php's People

Contributors

dsyph3r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

gai871013

curl-php's Issues

Header processing - Updating for HTTP spec compliance

Changes need to be made to handle HTTP headers according to the HTTP Spec.

  1. HTTP headers should end with CRLF but can end with LF. Need to ensure library can handle this
  2. HTTP headers are in the form of name: value. There maybe any number of white space characters between the name: and value part. Library currently will fail to handle this.
  3. HTTP status line parts should be split by 1 space, but library should handle any number of white space characters between parts (There are 2 parts here, HTTP version, Status Code, Status Message)

Incorrect processing of HTTP 100 Continue header

Example echo $response['response']:

HTTP/1.0 100 Continue

HTTP/1.0 200 OK
Date: Wed, 21 Sep 2011 12:54:49 GMT
Server: Apache/2.2.17 (Ubuntu)
X-Powered-By: PHP/5.3.5-1ubuntu7.2
Set-Cookie: PHPSESSID=9i8mj6uroahvasactro0bmapr0; path=/
cache-control: no-cache
Vary: Accept-Encoding
Content-Length: 223
Connection: close
Content-Type: text/html; charset=UTF-8

my custom data response is ok

Original Code:

$results = array(
'curl_info' => $response['curl_info'],
'status' => $response['curl_info']['http_code'],
'headers' => $this->splitHeaders($responseSplit[0]),
'data' => $responseSplit[1],
);

I changed :

'headers' => $this->splitHeaders($responseSplit[0]),
'data' => $responseSplit[1],

by:

'headers' => $this->splitHeaders($responseSplit[$responseCount-2]),
'data' => $responseSplit[$responseCount-1],

where $responseCount = count($responseSplit);

Example:
$responseSplit = explode("\r\n\r\n", $response['response']);
$responseCount = count($responseSplit);
$results = array(
'curl_info' => $response['curl_info'],
'status' => $response['curl_info']['http_code'],
'headers' => $this->splitHeaders($responseSplit[$responseCount-2]),
'data' => $responseSplit[$responseCount-1],
);
return $results;

Ignoring HTTP status code 100 if exists

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.