… | |
… | |
174 | memory (so the callback writes it to a file) or when only some |
174 | memory (so the callback writes it to a file) or when only some |
175 | information should be extracted, or when the body should be |
175 | information should be extracted, or when the body should be |
176 | processed incrementally. |
176 | processed incrementally. |
177 | |
177 | |
178 | It is usually preferred over doing your own body handling via |
178 | It is usually preferred over doing your own body handling via |
179 | "want_body_handle". |
179 | "want_body_handle", but in case of streaming APIs, where HTTP is |
|
|
180 | only used to create a connection, "want_body_handle" is the |
|
|
181 | better alternative, as it allows you to install your own event |
|
|
182 | handler, reducing resource usage. |
180 | |
183 | |
181 | want_body_handle => $enable |
184 | want_body_handle => $enable |
182 | When enabled (default is disabled), the behaviour of |
185 | When enabled (default is disabled), the behaviour of |
183 | AnyEvent::HTTP changes considerably: after parsing the headers, |
186 | AnyEvent::HTTP changes considerably: after parsing the headers, |
184 | and instead of downloading the body (if any), the completion |
187 | and instead of downloading the body (if any), the completion |
… | |
… | |
197 | initial headers, an interactive protocol is used (typical |
200 | initial headers, an interactive protocol is used (typical |
198 | example would be the push-style twitter API which starts a |
201 | example would be the push-style twitter API which starts a |
199 | JSON/XML stream). |
202 | JSON/XML stream). |
200 | |
203 | |
201 | If you think you need this, first have a look at "on_body", to |
204 | If you think you need this, first have a look at "on_body", to |
202 | see if that doesn'T solve your problem in a better way. |
205 | see if that doesn't solve your problem in a better way. |
203 | |
206 | |
204 | Example: make a simple HTTP GET request for http://www.nethype.de/ |
207 | Example: make a simple HTTP GET request for http://www.nethype.de/ |
205 | |
208 | |
206 | http_request GET => "http://www.nethype.de/", sub { |
209 | http_request GET => "http://www.nethype.de/", sub { |
207 | my ($body, $hdr) = @_; |
210 | my ($body, $hdr) = @_; |