2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FNetHttpHttpMessage.h
20 * @brief This is the header file for the %HttpMessage class.
22 * This header file contains the declarations of the %HttpMessage class.
25 #ifndef _FNET_HTTP_HTTP_MESSAGE_H_
26 #define _FNET_HTTP_HTTP_MESSAGE_H_
28 #include <FBaseByteBuffer.h>
29 #include <FBaseColQueue.h>
30 #include <FNetHttpHttpHeader.h>
32 namespace Tizen { namespace Net { namespace Http
34 class _HttpMessageImpl;
37 * @brief This class is the base class for HttpRequest and HttpResponse.
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.
45 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_connectivity.htm">HTTP Guide</a>.
48 class _OSP_EXPORT_ HttpMessage
49 : public Tizen::Base::Object
54 * This is the default constructor for this class.
61 * This destructor overrides Tizen::Base::Object::~Object().
65 virtual ~HttpMessage(void);
69 * Writes the message body. @n
70 * This method can be called several times consecutively. All the message bodies are stored in the queue.
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.
88 virtual result WriteBody(const Tizen::Base::ByteBuffer& body) = 0;
93 * This 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.
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.
105 virtual HttpHeader* GetHeader(void) const = 0;
108 * Gets the body of the message associated with HttpRequest or HttpResponse.
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.
126 virtual Tizen::Base::ByteBuffer* ReadBodyN(void) = 0;
130 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
132 * @param[in] rhs An instance of %HttpMessage
134 HttpMessage(const HttpMessage& rhs);
137 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
139 * @param[in] rhs An instance of %HttpMessage
141 HttpMessage& operator =(const HttpMessage& rhs);
145 // This variable is for internal use only. Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
147 // The total length of the message body
151 unsigned int _totalLen;
154 // This variable is for internal use only. Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
160 Tizen::Base::Collection::Queue _bodyQueue;
163 // This variable is for internal use only. Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
165 // The header of message
169 HttpHeader* _pHeader;
171 friend class _HttpMessageImpl;
172 _HttpMessageImpl* _pHttpMessageImpl;
176 } } } // Tizen::Net::Http
177 #endif // _FNET_HTTP_HTTP_MESSAGE_H_