reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
HttpGetMessage.cxx
Go to the documentation of this file.
3
4using namespace resip;
5
6
8 bool success,
9 const Data& body,
10 const Mime& type) :
12 mSuccess(success),
13 mBody(body),
14 mType(type),
15 mStatusCode(200)
16{
17}
18
20 const Data& userData,
21 unsigned int statusCode,
23 const Data& body,
24 const Mime& type) :
26 mSuccess(statusCode >= 200 && statusCode <= 299),
27 mBody(body),
28 mType(type),
29 mUserData(userData),
30 mStatusCode(statusCode),
31 mHeaders(std::move(headers))
32{
33}
34
35const Data&
37{
38 // Keys in mHeaders are stored lower-cased - lowercase the lookup key as well
39 Data lower(name);
40 lower.lowercase();
41 HeaderMap::const_iterator it = mHeaders.find(lower);
42 return (it != mHeaders.end()) ? it->second : Data::Empty;
43}
44
46HttpGetMessage::encodeBrief(EncodeStream& strm) const
47{
48 // If UserData is empty and StatusCode is 0, assume 1st constructor was used
49 if (mUserData.empty() && mStatusCode == 0)
50 {
51 return strm << "HttpGetMessage: tid=" << getTransactionId() << ", success=" << Data(mSuccess) << ", bodyType=" << mType;
52 }
53 else
54 {
55 return strm << "HttpGetMessage: tid=" << getTransactionId() << ", userData=" << mUserData << ", statusCode=" << mStatusCode << ", bodyType=" << mType;
56 }
57}
58
60HttpGetMessage::encode(EncodeStream& strm) const
61{
62 strm << brief() << ", headers={";
63
64 bool first = true;
65 for (HeaderMap::const_iterator it = mHeaders.begin(); it != mHeaders.end(); ++it)
66 {
67 if (!first) strm << ", ";
68 strm << it->first << ": " << it->second;
69 first = false;
70 }
71 strm << "}, body=" << mBody;
72 return strm;
73}
74
75Message*
77{
78 return new HttpGetMessage(getTransactionId(), mUserData, mStatusCode, mHeaders, mBody, mType);
79}
80
81/* ====================================================================
82 * The Vovida Software License, Version 1.0
83 *
84 * Copyright (c) 2026, SIP Spectrum, Inc. https://www.sipspectrum.com
85 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
86 *
87 * Redistribution and use in source and binary forms, with or without
88 * modification, are permitted provided that the following conditions
89 * are met:
90 *
91 * 1. Redistributions of source code must retain the above copyright
92 * notice, this list of conditions and the following disclaimer.
93 *
94 * 2. Redistributions in binary form must reproduce the above copyright
95 * notice, this list of conditions and the following disclaimer in
96 * the documentation and/or other materials provided with the
97 * distribution.
98 *
99 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
100 * and "Vovida Open Communication Application Library (VOCAL)" must
101 * not be used to endorse or promote products derived from this
102 * software without prior written permission. For written
103 * permission, please contact vocal@vovida.org.
104 *
105 * 4. Products derived from this software may not be called "VOCAL", nor
106 * may "VOCAL" appear in their name, without prior written
107 * permission of Vovida Networks, Inc.
108 *
109 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
110 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
111 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
112 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
113 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
114 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
115 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
116 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
117 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
118 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
119 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
120 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
121 * DAMAGE.
122 *
123 * ====================================================================
124 *
125 * This software consists of voluntary contributions made by Vovida
126 * Networks, Inc. and many individuals on behalf of Vovida Networks,
127 * Inc. For more information on Vovida Networks, Inc., please see
128 * <http://www.vovida.org/>.
129 *
130 */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static const Data Empty
Constant that represents a zero-length data.
Definition Data.hxx:882
bool empty() const noexcept
Checks whether the Data is empty.
Definition Data.hxx:591
Data & lowercase()
Converts this Data to lowercase.
Definition Data.cxx:1635
dcm! – what is the intent of ApplicationMessage, especially as used in
virtual const Data & getTransactionId() const
std::map< Data, Data > HeaderMap
HttpGetMessage(const Data &tid, bool success, const Data &body, const Mime &type)
const Data & getHeader(const Data &name) const
virtual Message * clone() const
virtual EncodeStream & encode(EncodeStream &strm) const
output the entire message to stream
virtual EncodeStream & encodeBrief(EncodeStream &strm) const
output a brief description to stream
The base-class used for message-passing.
Definition Message.hxx:21
virtual Brief brief() const
return a facet for brief encoding of message
Definition Message.cxx:16
Represents the "media-type" element in the RFC 3261 grammar.
Definition Mime.hxx:20
dcm! – add UnusedChecking(_enum) below;
#define EncodeStream