LEFT | RIGHT |
(no file at all) | |
1 /* | 1 /* |
2 * Copyright (c) 2011 Google Inc. | 2 * Copyright (c) 2011 Google Inc. |
3 * | 3 * |
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.apache.org/licenses/LICENSE-2.0 | 7 * http://www.apache.org/licenses/LICENSE-2.0 |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 httpRequest.setContent(createSerializer(body)); | 354 httpRequest.setContent(createSerializer(body)); |
355 } | 355 } |
356 return httpRequest; | 356 return httpRequest; |
357 } | 357 } |
358 | 358 |
359 /** | 359 /** |
360 * Builds and executes a {@link HttpRequest}. Subclasses may override if speci
fic behavior is | 360 * Builds and executes a {@link HttpRequest}. Subclasses may override if speci
fic behavior is |
361 * required, for example if a sequence of requests need to be built instead of
a single request. | 361 * required, for example if a sequence of requests need to be built instead of
a single request. |
362 * | 362 * |
363 * <p> | 363 * <p> |
364 * Callers are responsible for closing the response's content input stream by
calling | 364 * Callers are responsible for disconnecting the HTTP response by calling |
365 * {@link HttpResponse#ignore}. | 365 * {@link HttpResponse#disconnect}. Example usage: |
366 * </p> | 366 * </p> |
| 367 * |
| 368 * <pre> |
| 369 HttpResponse response = client.executeUnparsed(method, url, body); |
| 370 try { |
| 371 // process response.. |
| 372 } finally { |
| 373 response.disconnect(); |
| 374 } |
| 375 * </pre> |
367 * | 376 * |
368 * @param method HTTP Method type | 377 * @param method HTTP Method type |
369 * @param url The complete URL of the service where requests should be sent | 378 * @param url The complete URL of the service where requests should be sent |
370 * @param body A POJO that can be serialized into JSON or {@code null} for non
e | 379 * @param body A POJO that can be serialized into JSON or {@code null} for non
e |
371 * @return {@link HttpResponse} type | 380 * @return {@link HttpResponse} type |
372 * @throws IOException if the request fails | 381 * @throws IOException if the request fails |
373 * @since 1.7 | 382 * @since 1.7 |
374 */ | 383 */ |
375 protected HttpResponse executeUnparsed(HttpMethod method, GenericUrl url, Obje
ct body) | 384 protected HttpResponse executeUnparsed(HttpMethod method, GenericUrl url, Obje
ct body) |
376 throws IOException { | 385 throws IOException { |
377 HttpRequest request = buildHttpRequest(method, url, body); | 386 HttpRequest request = buildHttpRequest(method, url, body); |
378 return executeUnparsed(request); | 387 return executeUnparsed(request); |
379 } | 388 } |
380 | 389 |
381 /** | 390 /** |
382 * Executes the specified {@link HttpRequest}. Subclasses may override if spec
ific behavior is | 391 * Executes the specified {@link HttpRequest}. Subclasses may override if spec
ific behavior is |
383 * required, for example if a custom error is required to be thrown. | 392 * required, for example if a custom error is required to be thrown. |
384 * | 393 * |
385 * <p> | 394 * <p> |
386 * Callers are responsible for closing the response's content input stream by
calling | 395 * Callers are responsible for disconnecting the HTTP response by calling |
387 * {@link HttpResponse#ignore}. | 396 * {@link HttpResponse#disconnect}. Example usage: |
388 * </p> | 397 * </p> |
| 398 * |
| 399 * <pre> |
| 400 HttpResponse response = client.executeUnparsed(request); |
| 401 try { |
| 402 // process response.. |
| 403 } finally { |
| 404 response.disconnect(); |
| 405 } |
| 406 * </pre> |
389 * | 407 * |
390 * @param request HTTP Request | 408 * @param request HTTP Request |
391 * @return {@link HttpResponse} type | 409 * @return {@link HttpResponse} type |
392 * @throws IOException if the request fails | 410 * @throws IOException if the request fails |
393 * @since 1.9 | 411 * @since 1.9 |
394 */ | 412 */ |
395 protected HttpResponse executeUnparsed(HttpRequest request) throws IOException
{ | 413 protected HttpResponse executeUnparsed(HttpRequest request) throws IOException
{ |
396 return request.execute(); | 414 return request.execute(); |
397 } | 415 } |
398 | 416 |
399 /** | 417 /** |
400 * Builds and executes an {@link HttpRequest} and then returns the content inp
ut stream of | 418 * Builds and executes an {@link HttpRequest} and then returns the content inp
ut stream of |
401 * {@link HttpResponse}. Subclasses may override if specific behavior is requi
red. | 419 * {@link HttpResponse}. Subclasses may override if specific behavior is requi
red. |
402 * | 420 * |
403 * <p> | 421 * <p> |
404 * Callers are responsible for closing the input stream. | 422 * Callers are responsible for closing the input stream after it is processed.
Example usage: |
405 * </p> | 423 * </p> |
| 424 * |
| 425 * <pre> |
| 426 InputStream is = client.executeAsInputStream(); |
| 427 try { |
| 428 // Process input stream.. |
| 429 } finally { |
| 430 is.close(); |
| 431 } |
| 432 * </pre> |
406 * | 433 * |
407 * @param method HTTP Method type | 434 * @param method HTTP Method type |
408 * @param url The complete URL of the service where requests should be sent | 435 * @param url The complete URL of the service where requests should be sent |
409 * @param body A POJO that can be serialized into JSON or {@code null} for non
e | 436 * @param body A POJO that can be serialized into JSON or {@code null} for non
e |
410 * @return input stream of the response content | 437 * @return input stream of the response content |
411 * @throws IOException if the request fails | 438 * @throws IOException if the request fails |
412 * @since 1.8 | 439 * @since 1.8 |
413 */ | 440 */ |
414 protected InputStream executeAsInputStream(HttpMethod method, GenericUrl url,
Object body) | 441 protected InputStream executeAsInputStream(HttpMethod method, GenericUrl url,
Object body) |
415 throws IOException { | 442 throws IOException { |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 | 762 |
736 /** | 763 /** |
737 * Returns the application name to be used in the UserAgent header of each r
equest or {@code | 764 * Returns the application name to be used in the UserAgent header of each r
equest or {@code |
738 * null} for none. | 765 * null} for none. |
739 */ | 766 */ |
740 public final String getApplicationName() { | 767 public final String getApplicationName() { |
741 return applicationName; | 768 return applicationName; |
742 } | 769 } |
743 } | 770 } |
744 } | 771 } |
LEFT | RIGHT |