<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 請求主體 Every HTTP request has a body. If you are building a Slim application that consumes JSON or XML data, you can use the PSR-7 Request object’s`getParsedBody()`method to parse the HTTP request body into a native PHP format. Note that body parsing differs from one PSR-7 implementation to another. > 每個HTTP請求都有一個主體。如果您正在構建一個使用JSON或XML數據的slim應用程序,那么可以使用PSR-7請求對象的`getParsedBody()`方法將HTTP請求體解析為原生PHP格式。注意,不同的PSR-7實現之間的主體解析是不同的。 You may need to implement middleware in order to parse the incoming input depending on the PSR-7 implementation you have installed. Here is an example for parsing incoming`JSON`input: > 您可能需要實現中間件,以便根據安裝的PSR-7實現來解析輸入。下面是一個解析傳入`JSON`輸入的例子: ~~~php <?php use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface as RequestHandler; class JsonBodyParserMiddleware implements MiddlewareInterface { public function process(Request $request, RequestHandler $handler): Response { $contentType = $request->getHeaderLine('Content-Type'); if (strstr($contentType, 'application/json')) { $contents = json_decode(file_get_contents('php://input'), true); if (json_last_error() === JSON_ERROR_NONE) { $request = $request->withParsedBody($contents); } } return $handler->handle($request); } } ~~~ ~~~php $parsedBody = $request->getParsedBody(); ~~~ Figure 9: Parse HTTP request body into native PHP format Technically speaking, the PSR-7 Request object represents the HTTP request body as an instance of`Psr\Http\Message\StreamInterface`. You can get the HTTP request body`StreamInterface`instance with the PSR-7 Request object’s`getBody()`method. The`getBody()`method is preferable if the incoming HTTP request size is unknown or too large for available memory. > 從技術上講,Psr -7請求對象將HTTP請求體表示為`Psr\ HTTP \Message\StreamInterface`的一個實例。您可以使用PSR-7請求對象的`getBody()`方法獲得HTTP請求體`StreamInterface`實例。如果傳入的HTTP請求大小未知或者對于可用內存來說太大,則使用`getBody()`方法更好。 ~~~php $body = $request->getBody(); ~~~ Figure 10: Get HTTP request body The resultant`Psr\Http\Message\StreamInterface`instance provides the following methods to read and iterate its underlying PHP`resource`. > 由此產生的`Psr\Http\Message\StreamInterface`實例提供了以下方法來讀取和迭代它的底層PHP`資源`。 * getSize() * tell() * eof() * isSeekable() * seek() * rewind() * isWritable() * write($string) * isReadable() * read($length) * getContents() * getMetadata($key = null)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看