I hereby claim:
- I am rdlowrey on github.
- I am rdlowrey (https://keybase.io/rdlowrey) on keybase.
- I have a public key ASBeQKDHmLVbYmkyKlQ5gtlC1y41gcvv-rSB4tYjNJBqago
To claim this, I am signing this object:
<?php | |
/** | |
* Remove dot segments from a URI path according to RFC3986 Section 5.2.4 | |
* | |
* @param $path | |
* @return string | |
* @link http://www.ietf.org/rfc/rfc3986.txt | |
*/ | |
function removeDotPathSegments($path) { |
/* | |
$ npm install request | |
$ node bench.js | |
*/ | |
var request = require('request'); | |
var url = 'http://www.google.com'; | |
var total_requests = 100; | |
var i; |
<?php | |
// Connect asynchronously (new constant for bitwise arg 2: PGSQL_CONNECT_ASYNC) | |
if (!$db = pg_connect($conn_str, PGSQL_CONNECT_ASYNC)) { | |
echo "pg_connect() error\n"; | |
} elseif (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { | |
echo "pg_connect() error\n"; | |
} elseif (!$stream = pg_socket($db)) { | |
echo "pg_socket() error\n"; | |
} |
I hereby claim:
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
PHP disables SSL/TLS peer verification by default. While this design decision significantly simplifies encrypted HTTP retrieval, it also means your transfers are totally vulnerable to Man-in-the-Middle attacks. To fully secure our transfers we need to verify that the party at the other end of our transfer is actually who they say they are.
To accomplish this we need two things:
We can easily obtain the same CA file (direct link to .pem file) used by the Mozilla Foundation (the exact one cURL uses, BTW). This file is usually updated a handful of times each year and it's important to keep your CA file up-to-date or you risk trusting certificate authorities that are known to be insecure/unsafe. This kind of thing doesn't happen often, but it's important to upd
<?php | |
class Worker extends \Worker { | |
function run() { | |
// &$this ref required to avoid segfault | |
register_shutdown_function([&$this, 'onShutdown']); | |
} | |
private function onShutdown() { |
For many PHP devs, their first experience with HTTP request parameters comes in the form
of the $_GET
and $_POST
superglobals. These globally accessible arrays are an easily
digestable abstraction of the HTTP spec. Indeed, for basic applications operating only in
the context of common browser user-agents, these eminently accessible parameter collections
work well.
But there are some significant problems with $_GET
and $_POST
under the surface:
<?php | |
function myHttpHandler(Request $request, Response $response) { | |
// async function that returns a promise | |
// we use yield to wait for that promise to resolve then resume here | |
// if there's some kind of error it will be thrown into our generator | |
$session = yield loadSessionFromRequest($request); | |
if ($session->hasValue('isLoggedIn')) { | |
// pass the individual promises from generateHttpBody() through using `yield from` |