2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
19 * @file SoupMessageSendBase.h
20 * @brief Simple wrapper for soup.
22 #ifndef _SRC_VALIDATION_CORE_SOUP_MESSAGE_SEND_BASE_H_
23 #define _SRC_VALIDATION_CORE_SOUP_MESSAGE_SEND_BASE_H_
29 #include <libsoup/soup.h>
31 namespace SoupWrapper {
33 class SoupMessageSendBase {
36 typedef std::vector<char> MessageBuffer;
37 typedef std::map<std::string,std::string> HeaderMap;
41 REQUEST_STATUS_CONNECTION_ERROR
44 SoupMessageSendBase();
46 virtual ~SoupMessageSendBase();
49 * Add specific information to request header.
51 * @param[in] property property name (for example "Host")
52 * @param[in] value property value (for example "onet.pl:80")
54 void setHeader(const std::string &property,
55 const std::string &value);
58 * Set request destination.
60 * @param[in] host - full path to source (http://onet.pl/index.html)
62 void setHost(const std::string &host);
65 * Set body of request.
67 * @param[in] contentType (for example: "application/ocsp-request")
68 * @param[in] message body of reqeust
70 void setRequest(const std::string &contentType,
71 const MessageBuffer &message);
74 * Set network timeout. Default is 30 seconds.
76 * @param[in] seconds timeout in seconds
78 void setTimeout(int seconds);
81 * How many erros soup will accept before he will terminate connection.
84 * @param[in] retry number
86 void setRetry(int retry);
89 * Get response from serwer.
91 MessageBuffer getResponse() const;
95 SoupMessage* createRequest();
109 std::string m_requestType;
110 MessageBuffer m_requestBuffer;
111 MessageBuffer m_responseBuffer;
112 HeaderMap m_headerMap;
115 } // namespace ValidationCore