merge with master
[framework/osp/net.git] / src / inc / FNetHttp_HttpRequestImpl.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                FNetHttp_HttpRequestImpl.h
20  * @brief               This is the header file for the %_HttpRequestImpl class.
21  *
22  * This header file contains the declarations of the %_HttpRequestImpl class.
23  */
24
25 #ifndef _FNET_HTTP_INTERNAL_HTTP_REQUEST_IMPL_H_
26 #define _FNET_HTTP_INTERNAL_HTTP_REQUEST_IMPL_H_
27
28 #include <FOspConfig.h>
29 #include <FNetHttpHttpTypes.h>
30
31 namespace Tizen { namespace Base
32 {
33 class ByteBuffer;
34 class String;
35 } }
36
37 namespace Tizen { namespace Base { namespace Collection
38 {
39 class IList;
40 } } }
41
42 namespace Tizen { namespace Net { namespace Http
43 {
44 class IHttpEntity;
45 class HttpHeader;
46 class HttpRequest;
47 class HttpTransaction;
48 class _HttpTransactionImpl;
49 /**
50  * @class       _HttpRequestImpl
51  * @brief       This class represents a request message.
52  *
53  * @since 2.1
54  */
55
56 class _OSP_EXPORT_ _HttpRequestImpl
57         : public Tizen::Base::Object
58 {
59
60 public:
61         /**
62          * @see                 HttpRequest::Setmethod()
63          */
64         result SetMethod(NetHttpMethod method);
65
66         /**
67          * @see                 HttpRequest::SetCustomMethod()
68          */
69         result SetCustomMethod(const Tizen::Base::String& method);
70
71         /**
72          * @see                 HttpRequest::SetVersion()
73          */
74         result SetVersion(HttpVersion version);
75
76         /**
77          * @see                 HttpRequest::SetUri()
78          */
79         result SetUri(const Tizen::Base::String& uri);
80
81         /**
82          * @see                 HttpRequest::WriteBody()
83          */
84         virtual result WriteBody(const Tizen::Base::ByteBuffer& body);
85
86         /**
87          * @see                 HttpRequest::SetEntity()
88          */
89         result SetEntity(IHttpEntity& entity);
90
91         /**
92          * @see                 HttpRequest::GetHeader()
93          */
94         virtual HttpHeader* GetHeader(void) const;
95
96         /**
97          * @see                 HttpRequest::SetCookie()
98          */
99         result SetCookie(const Tizen::Base::String& cookieString);
100
101         /**
102          * @see                 HttpRequest::GetCookie()
103          */
104         Tizen::Base::String GetCookie(void) const;
105
106         /**
107          * @see                 HttpRequest::GetMethod()
108          */
109         NetHttpMethod GetMethod(void) const;
110
111         /**
112          * @see                 GetCustomMethod()
113          */
114         result GetCustomMethod(Tizen::Base::String& method) const;
115
116         /**
117          * @see                 GetVersion()
118          */
119         HttpVersion GetVersion(void) const;
120
121         /**
122          * @see                 HttpRequest::GetUri()
123          */
124         result GetUri(Tizen::Base::String& uri) const;
125
126         /**
127          * @see                 HttpRequest::ReadBodyN()
128          */
129         virtual Tizen::Base::ByteBuffer* ReadBodyN(void);
130
131         /**
132          * @see                 HttpRequest::SetAcceptEncoding()
133          */
134         result SetAcceptEncoding(const Tizen::Base::String& encoding);
135
136         /**
137          * @see                 HttpRequest::GetAcceptEncoding()
138          */
139         Tizen::Base::String GetAcceptEncoding(void) const;
140
141 public:
142         /**
143          * Gets the Impl instance.
144          *
145          * @since 2.1
146          * @return                      The pointer to _HttpRequestImpl
147          * @param[in]   pHttpRequest            An instance of HttpRequest
148          */
149         static _HttpRequestImpl* GetInstance(HttpRequest& httpRequest);
150
151         /**
152          * Gets the Impl instance.
153          *
154          * @since 2.1
155          * @return                      The pointer to _HttpRequestImpl
156          * @param[in]   pHttpRequest            An instance of HttpRequest
157          */
158         static const _HttpRequestImpl* GetInstance(const HttpRequest& httpRequest);
159
160 public:
161         _HttpRequestImpl(HttpRequest* pRequest);
162
163         virtual ~_HttpRequestImpl(void);
164
165         result Construct(const _HttpTransactionImpl& httpTransactionImpl, const HttpHeader* pCommonHeader);
166
167 public:
168         static HttpRequest* CreateHttpRequestN(void);
169
170         static void DeleteHttpRequest(HttpRequest* pHttpRequest);
171
172         bool IsEmptyBody(void) const;
173
174         unsigned int GetTotalBodyLength(void) const;
175
176         void SetRecommendedSize(int recommendedSize);
177
178         void SetReceivedTransactionReadyToWriteEvent(bool isReceviedEvent);
179
180         void SetFirstChunkBody(bool isFirstChunk);
181
182         bool IsFirstChunkBody(void) const;
183
184         bool IsLastChunkBody(void) const;
185
186         bool HasCookie(void) const;
187
188         void SetSendingBuffer(Tizen::Base::ByteBuffer* pBuffer);
189
190         Tizen::Base::ByteBuffer* GetSendingBuffer(void) const;
191
192         Tizen::Base::String GetMethodName(void) const;
193
194         Tizen::Base::ByteBuffer* ReadAllBodyN(void) const;
195
196         IHttpEntity* GetEntity(void) const;
197
198         bool HasNextData(void);
199
200         Tizen::Base::ByteBuffer* GetNextDataN(int recommendedSize);
201
202         result Set(_HttpRequestImpl* pHttpRequestImpl);
203
204 private:
205         _HttpRequestImpl(void);
206
207         _HttpRequestImpl(const _HttpRequestImpl& rhs);
208
209         _HttpRequestImpl& operator =(const _HttpRequestImpl& rhs);
210
211 private:
212         NetHttpMethod __method;
213         Tizen::Base::String __customMethodName;
214         Tizen::Base::String __methodName;
215         HttpVersion __httpVersion;
216         Tizen::Base::String __uri;
217         Tizen::Base::String __cookieValue;
218         NetHttpCookieFlag __cookieFlag;
219         Tizen::Base::String __encoding;
220         int __recommendedSize;
221         bool __isFirstChunk;
222         bool __isLastChunk;
223         bool __isReceivedTransactionReadyToWriteEvent;
224         IHttpEntity* __pIHttpEntity;
225         Tizen::Base::ByteBuffer* __pSendingBuffer;
226         _HttpTransactionImpl* __pHttpTransactionImpl;
227         HttpRequest* __pHttpRequest; //To access member variables of the HttpRequest(HttpMessage).
228
229         friend class HttpRequest;
230
231 }; // _HttpRequestImpl
232
233 } } } // Tizen::Net::Http
234 #endif // _FNET_HTTP_INTERNAL_HTTP_REQUEST_IMPL_H_