remove link in brief tag
[platform/framework/native/net.git] / inc / FNetHttpHttpMessage.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FNetHttpHttpMessage.h
20  * @brief               This is the header file for the %HttpMessage class.
21  *
22  * This header file contains the declarations of the %HttpMessage class.
23  */
24
25 #ifndef _FNET_HTTP_HTTP_MESSAGE_H_
26 #define _FNET_HTTP_HTTP_MESSAGE_H_
27
28 #include <FBaseByteBuffer.h>
29 #include <FBaseColQueue.h>
30 #include <FNetHttpHttpHeader.h>
31
32 namespace Tizen { namespace Net { namespace Http
33 {
34 class _HttpMessageImpl;
35 /**
36  * @class       HttpMessage
37  * @brief       This class is the base class for %HttpRequest and %HttpResponse.
38  *
39  * @since   2.0
40  *
41  * The %HttpMessage class represents the HTTP messages for the data exchanged between the client and the server, specifically for a request or a
42  * response. Both message types consist of a start line, zero or more header fields, an empty line indicating the end of the header fields, and
43  * possibly a message body.
44  *
45  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_connectivity.htm">HTTP Guide</a>.
46  */
47
48 class _OSP_EXPORT_ HttpMessage
49         : public Tizen::Base::Object
50 {
51
52 protected:
53         /**
54          * This is the default constructor for this class.
55          *
56          * @since 2.0
57          */
58         HttpMessage(void);
59
60         /**
61          * This destructor overrides Tizen::Base::Object::~Object().
62          *
63          * @since 2.0
64          */
65         virtual ~HttpMessage(void);
66
67 protected:
68         /**
69          * Writes the message body. @n
70          * The %WriteBody() method can be called several times consecutively. All the message bodies are stored in the queue.
71          *
72          * @since       2.0
73          *
74          * @return              An error code
75          * @param[in]   body                                            The message body data
76          * @exception   E_SUCCESS                                       The method is successful.
77          * @exception   E_INVALID_ARG                           The specified @c body contains an invalid value.
78          * @exception   E_OUT_OF_MEMORY                         The memory is insufficient.
79          * @exception   E_INVALID_SESSION                       The session handle is invalid.
80          * @exception   E_INVALID_TRANSACTION           The transaction handle is invalid.
81          * @exception   E_OUT_OF_RANGE                          The size of the specified body is out of range.
82          * @exception   E_INVALID_STATE                         The current state of the instance prohibits the execution of the specified operation.
83          * @exception   E_UNKNOWN                                       An unknown error has occurred.
84          * @remarks             This method only considers the data between the position and the limit of the Tizen::Base::ByteBuffer as valid.
85          *                              The position and limit has to be set appropriately before invoking this method.
86          * @see                 ReadBodyN()
87          */
88         virtual result WriteBody(const Tizen::Base::ByteBuffer& body) = 0;
89
90 protected:
91         /**
92          * Gets the header. @n
93          * The %GetHeader() method is used to access the headers associated with a transaction request or response.
94          * The handle is obtained from either the HttpRequest or the HttpResponse objects associated with the transaction. Adding, modifying, or removing a
95          * header field is done using this header handle.
96          *
97          * @since       2.0
98          *
99          * @return              The pointer to HttpHeader that is to modify, @n
100          *                              else @c null if %HttpMessage is not constructed
101          * @exception   E_SUCCESS                       The method is successful.
102          * @exception   E_INVALID_HEADER        The header is @c null.
103          * @remarks             The specific error code can be accessed using the GetLastResult() method.
104          */
105         virtual HttpHeader* GetHeader(void) const = 0;
106
107         /**
108          * Gets the body of the message associated with HttpRequest or HttpResponse.
109          *
110          * @since       2.0
111          *
112          * @return              The message body
113          * @exception   E_SUCCESS                               The method is successful.
114          * @exception   E_INVALID_STATE                 The method invoked is invalid. @n
115          *                                                                              Invoke this method before receiving a response body.
116          * @exception   E_EMPTY_BODY                    The requested body is empty.
117          * @exception   E_OUT_OF_RANGE                  The size of the message body is out of range.
118          * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
119          * @exception   E_IO                                    The method has failed to read the data.
120          * @exception   E_UNKNOWN                               An unknown error has occurred.
121          * @remarks             The specific error code can be accessed using the GetLastResult() method.
122          * @remarks             Once this method is invoked, the returned message body is removed from the message body queue.
123          *                              In other words, the message body queue does not hold all the bodies permanently.
124          * @see                 WriteBody()
125          */
126         virtual Tizen::Base::ByteBuffer* ReadBodyN(void) = 0;
127
128 private:
129         /**
130          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
131          *
132          * @param[in]   rhs   An instance of %HttpMessage
133          */
134         HttpMessage(const HttpMessage& rhs);
135
136         /**
137          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
138          *
139          * @param[in]   rhs                     An instance of %HttpMessage
140          */
141         HttpMessage& operator =(const HttpMessage& rhs);
142
143 protected:
144         //
145         //  This variable is for internal use only. Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
146         //
147         // The total length of the message body
148         //
149         // @since       2.0
150         //
151         unsigned int _totalLen;
152
153         //
154         //  This variable is for internal use only. Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
155         //
156         // The message queue
157         //
158         // @since       2.0
159         //
160         Tizen::Base::Collection::Queue _bodyQueue;
161
162         //
163         //  This variable is for internal use only. Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
164         //
165         // The header of the message
166         //
167         // @since       2.0
168         //
169         HttpHeader* _pHeader;
170
171         friend class _HttpMessageImpl;
172         _HttpMessageImpl* _pHttpMessageImpl;
173
174 }; // HttpMessage
175
176 } } } // Tizen::Net::Http
177 #endif // _FNET_HTTP_HTTP_MESSAGE_H_