Lines Matching full:body
75 ### Working with HTTP Message Body
78 #### 1. Getting the body separately
80 > This method makes the body handling easier to understand and is useful when repeatedly calling bo…
83 $body = $response->getBody();
84 // operations on body, eg. read, write, seek
86 // replacing the old body
87 $response->withBody($body);
89 // in this case the "new" body is same with the "old" one
90 // the $body variable has the same value as the one in $request, only the reference is passed
101 ### Getting the body contents
106 $body = $response->getBody();
107 $body->rewind(); // or $body->seek(0);
108 $bodyText = $body->getContents();
110 …body->seek(1)` is called before `$body->getContents()`, the first character will be ommited as the…
112 ### Append to body
116 $body = $request->getBody(); // which is a `StreamInterface`
117 $body->write('xxxxx');
120 ### Prepend to body
126 $body = $repsonse->getBody();
128 $body->write('abcd');
131 $body->seek(0);
133 $body->write('ef'); // at this point the stream contains "efcd"
139 // assuming our response body stream only contains: "abcd"
140 $body = $response->getBody();
141 $body->rewind();
142 $contents = $body->getContents(); // abcd
144 $body->rewind();
145 $body->write('ef'); // stream contains "efcd"
146 $body->write($contents); // stream contains "efabcd"
153 $body = $response->getBody();
154 $body->rewind();
155 $contents = $body->getContents(); // efabcd
157 $body->rewind();
158 $body->write($contents);