All Projects → sinacms → MultiHttp

sinacms / MultiHttp

Licence: other
This is a high performance , very useful multi-curl tool written in php. 一个超级好用的并发CURL工具!!!(httpful,restful, concurrency)

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to MultiHttp

Corium
Corium is a modern scripting language which combines simple, safe and efficient programming.
Stars: ✭ 18 (-77.22%)
Mutual labels:  high-performance, concurrency, parallel, multithreading
java-multithread
Códigos feitos para o curso de Multithreading com Java, no canal RinaldoDev do YouTube.
Stars: ✭ 24 (-69.62%)
Mutual labels:  concurrency, parallel, multithreading
thread-pool
BS::thread_pool: a fast, lightweight, and easy-to-use C++17 thread pool library
Stars: ✭ 1,043 (+1220.25%)
Mutual labels:  concurrency, parallel, multithreading
noroutine
Goroutine analogue for Node.js, spreads I/O-bound routine calls to utilize thread pool (worker_threads) using balancer with event loop utilization. 🌱
Stars: ✭ 86 (+8.86%)
Mutual labels:  concurrency, parallel, multithreading
wasm-bindgen-rayon
An adapter for enabling Rayon-based concurrency on the Web with WebAssembly.
Stars: ✭ 257 (+225.32%)
Mutual labels:  concurrency, parallel, multithreading
Hamsters.js
100% Vanilla Javascript Multithreading & Parallel Execution Library
Stars: ✭ 517 (+554.43%)
Mutual labels:  concurrency, parallel, multithreading
Object threadsafe
We make any object thread-safe and std::shared_mutex 10 times faster to achieve the speed of lock-free algorithms on >85% reads
Stars: ✭ 280 (+254.43%)
Mutual labels:  high-performance, concurrency, multithreading
Linux-Kernel-Driver-Programming
Implementation of PCI drivers, kprobe, sysfs, devfs, sensor driver, miscdevices, synchronization
Stars: ✭ 43 (-45.57%)
Mutual labels:  concurrency, parallel
YACLib
Yet Another Concurrency Library
Stars: ✭ 193 (+144.3%)
Mutual labels:  concurrency, parallel
kafka-workers
Kafka Workers is a client library which unifies records consuming from Kafka and processing them by user-defined WorkerTasks.
Stars: ✭ 30 (-62.03%)
Mutual labels:  parallel, multithreading
thread-pool
A modern thread pool implementation based on C++20
Stars: ✭ 104 (+31.65%)
Mutual labels:  high-performance, concurrency
pooljs
Browser computing unleashed!
Stars: ✭ 17 (-78.48%)
Mutual labels:  parallel, multithreading
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (-74.68%)
Mutual labels:  concurrency, parallel
workerpoolxt
Concurrency limiting goroutine pool without upper limit on queue length. Extends github.com/gammazero/workerpool
Stars: ✭ 15 (-81.01%)
Mutual labels:  concurrency, multithreading
bascomtask
Lightweight parallel Java tasks
Stars: ✭ 49 (-37.97%)
Mutual labels:  concurrency, parallel
hatrack
Fast, multi-reader, multi-writer, lockless data structures for parallel programming
Stars: ✭ 55 (-30.38%)
Mutual labels:  high-performance, parallel
go-worker-thread-pool
A visual working example of a Thread Pool pattern, based on a known blog article.
Stars: ✭ 24 (-69.62%)
Mutual labels:  concurrency, parallel
theater
Actor framework for Dart. This package makes it easier to work with isolates, create clusters of isolates.
Stars: ✭ 29 (-63.29%)
Mutual labels:  concurrency, multithreading
Curl Easy
cURL wrapper for PHP. Supports parallel and non-blocking requests. For high speed crawling, see stil/curl-robot
Stars: ✭ 297 (+275.95%)
Mutual labels:  curl, parallel
Faster Than Requests
Faster requests on Python 3
Stars: ✭ 639 (+708.86%)
Mutual labels:  curl, high-performance

MultiHttp

   This is high performance curl wrapper written in pure PHP. It's compatible with PHP 5.4+ and HHVM. Notice that libcurl version must be over 7.36.0, otherwise timeout can not suppert decimal.

   这是一个高性能的PHP封装的HTTP Restful多线程并发请求库,参考借鉴了httpful 、multirequest等优秀的代码。它与PHP 5.4和hhvm兼容。 注意,libcurl版本必须>=7.36.0,否则超时不支持小数。

## 请使用最新 Tag ( Please use the latest tag version)

Contents

Feature

  • alias of curl option, e.g. 'timeout' equals 'CURLOPT_TIMEOUT' etc.
  • Request and MultiRequest class , can be used in any combination
  • graceful and efficient

Installation

You can use composer to install this library from the command line.

composer require sinacms/multihttp

Usage

Single-request:

<?php
// Include Composer's autoload file if not already included.
require_once __DIR__.'/vendor/autoload.php';
use MultiHttp\Request;
use MultiHttp\Response;

//method 1
Request::create()->get('http://sina.com.cn', array(
          'timeout' => 3,
	  'expects_mime'=>'json',
	  'retry_times' => 3,
	  'ip' => '127.0.0.1:8080',//alias for proxy, better than raw proxy
          'callback' => function (Response $response) {
              echo $response->body;
          },
          ))->send();
      
//method 2
$result = Request::create()->post(
      'http://127.0.0.1',array('data'=>'this_is_post_data'), array(
          'callback' => function (Response $response) {
              echo $response->body;
          }))->send();

Multi-request:

<?php
require_once __DIR__.'/vendor/autoload.php';
use MultiHttp\MultiRequest;
use MultiHttp\Response;


$mr  = MultiRequest::create();
$rtn = $mr->add('GET', 'http://sina.cn',array(), array(
                  'timeout' => 3,
                  'callback' => function (Response $response) {
                                  echo $response->body;
                              }
              ))
          ->add('GET', 'http://google.cn',array(), array(
                  'timeout' => 3,
                  'callback' => function (Response $response) {
                                  echo $response->body;
                              }
              ))    
	      ->sendAll();

?>

Documentation

  • Request

  • option shorthand

       'url'             => 'CURLOPT_URL',
       'debug'           => 'CURLOPT_VERBOSE',//for debug verbose
       'method'          => 'CURLOPT_CUSTOMREQUEST',
       'data'            => 'CURLOPT_POSTFIELDS', // array or string , file begin with '@'
       'ua'              => 'CURLOPT_USERAGENT',
       'timeout'         => 'CURLOPT_TIMEOUT', // (secs) 0 means indefinitely
       'connect_timeout' => 'CURLOPT_CONNECTTIMEOUT',
       'referer'         => 'CURLOPT_REFERER',
       'binary'          => 'CURLOPT_BINARYTRANSFER',
       'port'            => 'CURLOPT_PORT',
       'header'          => 'CURLOPT_HEADER', // TRUE:include header
       'headers'         => 'CURLOPT_HTTPHEADER', // array
       'download'        => 'CURLOPT_FILE', // writing file stream (using fopen()), default is STDOUT
       'upload'          => 'CURLOPT_INFILE', // reading file stream
       'transfer'        => 'CURLOPT_RETURNTRANSFER', // TRUE:return string; FALSE:output directly (curl_exec)
       'follow_location' => 'CURLOPT_FOLLOWLOCATION',
       'timeout_ms'      => 'CURLOPT_TIMEOUT_MS', // milliseconds,  libcurl version > 7.36.0 ,
    
  • public static function create()

  • public function endCallback()

  • public function hasEndCallback()

  • public function onEnd(callable$callback)

  • public function uri

  • public function getIni($field)

  • public function addQuery($data)

  • public function post($uri, array $payload = array(), array $options = array())

  • public function addOptions(array $options = array())

  • public function get($uri, array $options = array())

  • public function send()

  • public function applyOptions()

  • public function makeResponse($isMultiCurl = false)

  • MultiRequest

  • public static function create()

  • public function addOptions(array $URLOptions)

  • public function add($method, $uri, array $payload = array(), array $options = array())

  • public function import(Request $request)

  • public function sendAll()

[More]https://github.com/sinacms/MultiHttp/blob/master/usage.md

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].