<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 響應體 An HTTP response typically has a body. > HTTP響應通常有一個主體。 Just like the PSR-7 Request object, the PSR-7 Response object implements the body as an instance of`Psr\Http\Message\StreamInterface`. You can get the HTTP response body`StreamInterface`instance with the PSR-7 Response object’s`getBody()`method. The`getBody()`method is preferable if the outgoing HTTP response length is unknown or too large for available memory. > 與Psr -7請求對象一樣,Psr -7響應對象將主體作為`Psr\Http\Message\StreamInterface`的實例實現。您可以使用PSR-7響應對象的`getBody()`方法獲得HTTP響應體`StreamInterface`實例。如果傳出HTTP響應長度未知或對于可用內存來說太大,則使用`getBody()`方法更好。 ~~~php $body = $response->getBody(); ~~~ Figure 12: Get HTTP response body The resultant`Psr\Http\Message\StreamInterface`instance provides the following methods to read from, iterate, and write to 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) Most often, you’ll need to write to the PSR-7 Response object. You can write content to the`StreamInterface`instance with its`write()`method like this: > 通常,您需要向PSR-7響應對象寫入內容。你可以用它的`write()`方法將內容寫入`StreamInterface`實例,如下所示: ~~~php $body = $response->getBody(); $body->write('Hello'); ~~~ Figure 13: Write content to the HTTP response body You can also*replace*the PSR-7 Response object’s body with an entirely new`StreamInterface`instance. This is particularly useful when you want to pipe content from a remote destination (e.g. the filesystem or a remote API) into the HTTP response. You can replace the PSR-7 Response object’s body with its`withBody(StreamInterface $body)`method. Its argument**MUST**be an instance of`Psr\Http\Message\StreamInterface`. > 您還可以用一個全新的`StreamInterface`實例`替換`PSR-7響應對象的主體。當您希望將內容從遠程目標(例如文件系統或遠程API)導入HTTP響應時,這一點特別有用。您可以用它的`withbody (StreamInterface $body)`方法替換PSR-7響應對象的主體。它的參數**必須是`Psr\Http\Message\StreamInterface`的一個實例。 ~~~php use GuzzleHttp\Psr7\LazyOpenStream; $newStream = new LazyOpenStream('/path/to/file', 'r'); $newResponse = $oldResponse->withBody($newStream); ~~~ Figure 14: Replace the HTTP response body **Reminder** The Response object is immutable. This method returns a*copy*of the Response object that contains the new body. > 提醒 > Response對象是不可變的。此方法返回包含新主體的響應對象的副本。
                  <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>

                              哎呀哎呀视频在线观看