git clone https://gist.github.com/af6ae792fd1aba13bfff.git
composer install
php index.php
Last active
August 29, 2015 14:01
-
-
Save vonglasow/af6ae792fd1aba13bfff to your computer and use it in GitHub Desktop.
Hoa Http request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "root/hoahttp", | |
"require": { | |
"hoa/core": "dev-master", | |
"hoa/socket": "dev-master", | |
"hoa/http": "dev-master" | |
}, | |
"minimum-stability": "dev" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_readme": [ | |
"This file locks the dependencies of your project to a known state", | |
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" | |
], | |
"hash": "c9afd2d4d1dbc0af7cb4802996dddd4f", | |
"packages": [ | |
{ | |
"name": "hoa/core", | |
"version": "dev-master", | |
"target-dir": "Hoa/Core", | |
"source": { | |
"type": "git", | |
"url": "https://github.com/hoaproject/Core.git", | |
"reference": "9525930f01c734ac3dcec2d5aee6ee3e9f616023" | |
}, | |
"dist": { | |
"type": "zip", | |
"url": "https://api.github.com/repos/hoaproject/Core/zipball/9525930f01c734ac3dcec2d5aee6ee3e9f616023", | |
"reference": "9525930f01c734ac3dcec2d5aee6ee3e9f616023", | |
"shasum": "" | |
}, | |
"require": { | |
"ext-spl": "*", | |
"php": ">=5.3.3" | |
}, | |
"suggest": { | |
"ext-mbstring": "ext/mbstring must be present (or a third implementation).", | |
"hoa/console": "To use the `hoa` script.", | |
"hoa/dispatcher": "To use the `hoa` script.", | |
"hoa/router": "To use the `hoa` script." | |
}, | |
"bin": [ | |
"Bin/hoa" | |
], | |
"type": "library", | |
"autoload": { | |
"psr-0": { | |
"Hoa\\Core": "." | |
}, | |
"files": [ | |
"Core.php" | |
] | |
}, | |
"notification-url": "https://packagist.org/downloads/", | |
"license": [ | |
"BSD-3-Clause" | |
], | |
"authors": [ | |
{ | |
"name": "Ivan Enderlin", | |
"email": "ivan.enderlin@hoa-project.net" | |
}, | |
{ | |
"name": "Hoa community", | |
"homepage": "http://hoa-project.net/" | |
} | |
], | |
"description": "The Hoa\\Core library.", | |
"homepage": "http://hoa-project.net/", | |
"keywords": [ | |
"consistency", | |
"core", | |
"data", | |
"event", | |
"library", | |
"listener", | |
"parameter", | |
"protocol" | |
], | |
"time": "2014-05-06 10:18:04" | |
}, | |
{ | |
"name": "hoa/http", | |
"version": "dev-master", | |
"target-dir": "Hoa/Http", | |
"source": { | |
"type": "git", | |
"url": "https://github.com/hoaproject/Http.git", | |
"reference": "53ed3e651d872432b5d6fefcdb2d2ef43c08640b" | |
}, | |
"dist": { | |
"type": "zip", | |
"url": "https://api.github.com/repos/hoaproject/Http/zipball/53ed3e651d872432b5d6fefcdb2d2ef43c08640b", | |
"reference": "53ed3e651d872432b5d6fefcdb2d2ef43c08640b", | |
"shasum": "" | |
}, | |
"require": { | |
"hoa/core": "dev-master", | |
"hoa/stream": "dev-master" | |
}, | |
"type": "library", | |
"autoload": { | |
"psr-0": { | |
"Hoa\\Http": "." | |
} | |
}, | |
"notification-url": "https://packagist.org/downloads/", | |
"license": [ | |
"BSD-3-Clause" | |
], | |
"authors": [ | |
{ | |
"name": "Ivan Enderlin", | |
"email": "ivan.enderlin@hoa-project.net" | |
}, | |
{ | |
"name": "Hoa community", | |
"homepage": "http://hoa-project.net/" | |
} | |
], | |
"description": "The Hoa\\Http library.", | |
"homepage": "http://hoa-project.net/", | |
"keywords": [ | |
"http", | |
"library", | |
"request", | |
"response", | |
"runtime" | |
], | |
"time": "2014-02-06 13:16:23" | |
}, | |
{ | |
"name": "hoa/socket", | |
"version": "dev-master", | |
"target-dir": "Hoa/Socket", | |
"source": { | |
"type": "git", | |
"url": "https://github.com/hoaproject/Socket.git", | |
"reference": "c0820fa8eee12d2d375818fe5877a0853d6a3246" | |
}, | |
"dist": { | |
"type": "zip", | |
"url": "https://api.github.com/repos/hoaproject/Socket/zipball/c0820fa8eee12d2d375818fe5877a0853d6a3246", | |
"reference": "c0820fa8eee12d2d375818fe5877a0853d6a3246", | |
"shasum": "" | |
}, | |
"require": { | |
"hoa/core": "dev-master", | |
"hoa/stream": "dev-master" | |
}, | |
"type": "library", | |
"autoload": { | |
"psr-0": { | |
"Hoa\\Socket": "." | |
} | |
}, | |
"notification-url": "https://packagist.org/downloads/", | |
"license": [ | |
"BSD-3-Clause" | |
], | |
"authors": [ | |
{ | |
"name": "Ivan Enderlin", | |
"email": "ivan.enderlin@hoa-project.net" | |
}, | |
{ | |
"name": "Hoa community", | |
"homepage": "http://hoa-project.net/" | |
} | |
], | |
"description": "The Hoa\\Socket library.", | |
"homepage": "http://hoa-project.net/", | |
"keywords": [ | |
"Socket", | |
"client", | |
"library", | |
"node", | |
"server", | |
"tcp", | |
"udp" | |
], | |
"time": "2014-05-07 16:00:22" | |
}, | |
{ | |
"name": "hoa/stream", | |
"version": "dev-master", | |
"target-dir": "Hoa/Stream", | |
"source": { | |
"type": "git", | |
"url": "https://github.com/hoaproject/Stream.git", | |
"reference": "d1d2388abd3581dff63a44dff9f224c006e06c21" | |
}, | |
"dist": { | |
"type": "zip", | |
"url": "https://api.github.com/repos/hoaproject/Stream/zipball/d1d2388abd3581dff63a44dff9f224c006e06c21", | |
"reference": "d1d2388abd3581dff63a44dff9f224c006e06c21", | |
"shasum": "" | |
}, | |
"require": { | |
"hoa/core": "dev-master" | |
}, | |
"type": "library", | |
"autoload": { | |
"psr-0": { | |
"Hoa\\Stream": "." | |
} | |
}, | |
"notification-url": "https://packagist.org/downloads/", | |
"license": [ | |
"BSD-3-Clause" | |
], | |
"authors": [ | |
{ | |
"name": "Ivan Enderlin", | |
"email": "ivan.enderlin@hoa-project.net" | |
}, | |
{ | |
"name": "Hoa community", | |
"homepage": "http://hoa-project.net/" | |
} | |
], | |
"description": "The Hoa\\Stream library.", | |
"homepage": "http://hoa-project.net/", | |
"keywords": [ | |
"Context", | |
"bucket", | |
"composite", | |
"filter", | |
"in", | |
"library", | |
"out", | |
"protocol", | |
"stream", | |
"wrapper" | |
], | |
"time": "2014-01-26 21:19:23" | |
} | |
], | |
"packages-dev": [ | |
], | |
"aliases": [ | |
], | |
"minimum-stability": "dev", | |
"stability-flags": { | |
"hoa/core": 20, | |
"hoa/socket": 20, | |
"hoa/http": 20 | |
}, | |
"platform": [ | |
], | |
"platform-dev": [ | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'vendor/autoload.php'; | |
$url = 'http://central.hoa-project.net/Resource/Library/Websocket'; | |
function byhoa($url) { | |
$url = parse_url($url); | |
$client = new \Hoa\Socket\Client('tcp://'. $url['host'] . ':80'); | |
$client->connect(); | |
$out = "HEAD " . $url['path'] . " HTTP/1.1\r\n"; | |
//$out .= "User-Agent: curl/7.26.0\r\n"; | |
$out .= "Host: " . $url['host'] . "\r\n"; | |
$out .= "Accept: */*\r\n"; | |
$out .= "\r\n"; | |
//$out .= "Connection: Keep-Alive\r\n\r\n"; | |
$client->writeAll($out); | |
$response = new \Hoa\Http\Response\Response(); | |
$a = $client->readAll(); | |
$response->parse($a); | |
return $response['status']; | |
} | |
function bycurl($url) | |
{ | |
$curl = curl_init($url); | |
curl_setopt($curl, CURLOPT_HEADER, true); | |
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); | |
curl_setopt($curl, CURLOPT_MAXREDIRS, 3); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
curl_exec($curl); | |
if(!curl_errno($curl)) | |
{ | |
$code = curl_getinfo($curl)['http_code']; | |
curl_close($curl); | |
return $code; | |
} | |
} | |
var_dump(byhoa($url)); | |
var_dump(bycurl($url)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment