X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=http%2FClient.md;h=639af26b7bd65fc7a6f8c9d7fe1b2bfd9753b157;hb=3bf080fbfef8496240a6d42d4a2d4c08c04cf8fd;hp=d86ad75f62ae6c1a85f49ebc14860afdbaba914d;hpb=e62e3fe51ec3cd99e8141a22cb0daafe7f7a4bbe;p=mdref%2Fmdref-http diff --git a/http/Client.md b/http/Client.md index d86ad75..639af26 100644 --- a/http/Client.md +++ b/http/Client.md @@ -2,104 +2,20 @@ The HTTP client. See http\Client\Curl's [options](http/Client/Curl#Options:) which is the only driver currently supported. -## Examples: - -### Sending a simple GET request: - - "My Client/0.1"] - ); - $request->setOptions(["timeout"=>1]); - - $client = new http\Client; - $client->enqueue($request)->send(); - - // pop the last retrieved response - $response = $client->getResponse(); - printf("%s returned '%s' (%d)\n", - $response->getTransferInfo("effective_url"), - $response->getInfo(), - $response->getResponseCode() - ); - ?> - -#### Yields: - - http://localhost/ returned 'HTTP/1.1 200 OK' (200) - - -### Submitting a standard form: - - "application/x-www-form-urlencoded"] - ); - $request->getBody()->append(new http\QueryString([ - "user" => "mike", - "name" => "Michael Wallner" - ])); - - $client = new http\Client; - $client->setOptions(["ssl" => [ - "version" => http\Client\Curl\SSL_VERSION_TLSv1 - ]]); - $client->enqueue($request)->send(); - - // ask for the response for this specific request - $response = $client->getResponse($request); - printf("-> %s\n", $response->getInfo()); - - ?> - -#### Yields: - - -> HTTP/1.1 200 OK - - -### Submitting a multipart form: - - getBody()->addForm([ - "user" => "mike", - "name" => "Michael Wallner" - ], [ - [ - "name" => "image", - "type" => "image/jpeg", - "file" => "image.jpg" - ] - ]); - - $client = new http\Client; - $client->setOptions(["ssl" => [ - "version" => http\Client\Curl\SSL_VERSION_TLSv1 - ]]); - $client->enqueue($request)->send(); - - // ask for the response for this specific request - $response = $client->getResponse($request); - printf("-> %.2F kB\n @ %.2F Mbit", - .001 * $response->getTransferInfo("size_upload"), - .0000008 * $response->getTransferInfo("speed_upload") - ); - ?> - -#### Yields: - - -> 15.98 kB @ 6.77 Mbit - +## Constants: + +* DEBUG_INFO + Debug callback's $data contains human readable text. +* DEBUG_IN + Debug callback's $data contains data received. +* DEBUG_OUT + Debug callback's $data contains data sent. +* DEBUG_HEADER + Debug callback's $data contains headers. +* DEBUG_BODY + Debug callback's $data contains a body part. +* DEBUG_SSL + Debug callback's $data contains SSL data. ## Properties: