PSR风格

  1. $bufferStream = new BufferStream();
  2. $bufferStream->write(json_encode(['foo' => 'bar']));
  3. $response = SaberGM::psr()
  4. ->withMethod('POST')
  5. ->withUri(new Uri('http://httpbin.org/post?foo=bar'))
  6. ->withQueryParams(['foo' => 'option is higher-level than uri'])
  7. ->withHeader('content-type', ContentType::JSON)
  8. ->withBody($bufferStream)
  9. ->exec()->recv();
  10. echo $response->getBody();