Code Monkey home page Code Monkey logo

http_request2's Introduction

HTTP_Request2

Build Status

Provides an easy way to perform HTTP requests, uses pluggable adapters

  • Socket: pure PHP implementation of HTTP protocol (does not use http stream wrapper), based on older PEAR HTTP_Request package
  • Curl: wrapper around PHP's cURL extension
  • Mock: used for testing packages depending on HTTP_Request2, returns predefined responses without network interaction

Both Socket and Curl adapters support POST requests with data and file uploads, basic and digest authentication, cookies, managing cookies across requests, HTTP and SOCKS5 proxies, gzip and deflate encodings, redirects, monitoring the request progress with Observers...

This package is PEAR HTTP_Request2 and has been migrated from PEAR SVN

Please report all issues via the PEAR bug tracker.

Pull requests are welcome.

Basic usage

require_once 'HTTP/Request2.php';

$request = new HTTP_Request2('http://pear.php.net/', HTTP_Request2::METHOD_GET);
try {
    $response = $request->send();
    if (200 == $response->getStatus()) {
        echo $response->getBody();
    } else {
        echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
             $response->getReasonPhrase();
    }
} catch (HTTP_Request2_Exception $e) {
    echo 'Error: ' . $e->getMessage();
}

Documentation

...is available on PEAR website

Generated API documentation for the current release is also there.

Testing, Packaging and Installing (Pear)

To test, run either

$ phpunit tests/

or

$ pear run-tests -r

You may need to set up the NetworkConfig.php file if you want to perform tests that interact with a web server. Its template is NetworkConfig.php.dist file, consult it for the details.

To build, simply

$ pear package

To install from scratch

$ pear install package.xml

To upgrade

$ pear upgrade -f package.xml

http_request2's People

Contributors

clockwerx avatar deliank avatar gauthierm avatar ktomk avatar mrook avatar phansys avatar sad-spirit avatar

Stargazers

 avatar

Watchers

 avatar

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.