atscppapi
1.0.9
C++ wrapper for Apache Traffic Server API
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Enumerations
Enumerator
Macros
src
include
atscppapi
AsyncHttpFetch.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2013 LinkedIn Corp. All rights reserved.
3
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
4
* except in compliance with the License. You may obtain a copy of the license at
5
* http://www.apache.org/licenses/LICENSE-2.0
6
*
7
* Unless required by applicable law or agreed to in writing, software distributed under the
8
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
9
* either express or implied.
10
*
11
*/
12
13
/**
14
* @file AsyncHttpFetch.h
15
* @author Brian Geffon
16
* @author Manjesh Nilange
17
*/
18
19
#pragma once
20
#ifndef ATSCPPAPI_ASYNCHTTPFETCH_H_
21
#define ATSCPPAPI_ASYNCHTTPFETCH_H_
22
23
#include <string>
24
#include <
atscppapi/shared_ptr.h
>
25
#include <
atscppapi/Async.h
>
26
#include <
atscppapi/Request.h
>
27
#include <
atscppapi/Response.h
>
28
29
namespace
atscppapi {
30
31
// forward declarations
32
class
AsyncHttpFetchState;
33
namespace
utils {
class
internal; }
34
35
/**
36
* @brief This class provides an implementation of AsyncProvider that
37
* makes HTTP requests asynchronously. This provider automatically
38
* self-destructs after the completion of the request.
39
*
40
* See example async_http_fetch for sample usage.
41
*/
42
class
AsyncHttpFetch
:
public
AsyncProvider
{
43
public
:
44
AsyncHttpFetch
(
const
std::string &url_str, HttpMethod http_method = HTTP_METHOD_GET);
45
46
/**
47
* Used to manipulate the headers of the request to be made.
48
*
49
* @return A reference to mutable headers.
50
*/
51
Headers
&
getRequestHeaders
();
52
53
enum
Result { RESULT_SUCCESS = 10000, RESULT_TIMEOUT, RESULT_FAILURE };
54
55
/**
56
* Used to extract the response after request completion.
57
*
58
* @return Result of the operation
59
*/
60
Result
getResult
()
const
;
61
62
/**
63
* @return Non-mutable reference to the request URL.
64
*/
65
const
Url
&
getRequestUrl
()
const
;
66
67
/**
68
* Used to extract the response after request completion.
69
*
70
* @return Non-mutable reference to the response.
71
*/
72
const
Response
&
getResponse
()
const
;
73
74
/**
75
* Used to extract the body of the response after request completion. On
76
* unsuccessful completion, values (NULL, 0) are set.
77
*
78
* @param body Output argument; will point to the body
79
* @param body_size Output argument; will contain the size of the body
80
*
81
*/
82
void
getResponseBody
(
const
void
*&body,
size_t
&body_size)
const
;
83
84
virtual
~
AsyncHttpFetch
();
85
86
/**
87
* Starts a HTTP fetch of the Request contained.
88
*/
89
virtual
void
run
(shared_ptr<AsyncDispatchControllerBase> dispatch_controller);
90
91
private
:
92
AsyncHttpFetchState *state_;
93
friend
class
utils::internal;
94
};
95
96
}
/* atscppapi */
97
98
#endif
/* ATSCPPAPI_ASYNCHTTPFETCH_H_ */
Generated on Mon Oct 14 2013 11:39:29 for atscppapi by
1.8.3.1