reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
MultipartMixedContents.hxx
Go to the documentation of this file.
1#if !defined(RESIP_MULTIPARTMIXEDCONTENTS_HXX)
2#define RESIP_MULTIPARTMIXEDCONTENTS_HXX
3
4#include <vector>
5
7#include "rutil/Data.hxx"
8
9namespace resip
10{
11
12class Mime;
13class ParseBuffer;
14
20{
21 public:
23 explicit MultipartMixedContents(const Mime& contentType);
24 MultipartMixedContents(const HeaderFieldValue& hfv, const Mime& contentType);
28
32 virtual Contents* clone() const;
33
34 static const Mime& getStaticType() ;
35
36 virtual EncodeStream& encodeParsed(EncodeStream& str) const;
37 virtual void parse(ParseBuffer& pb);
38
39 typedef std::vector<Contents*> Parts;
40 // Mutable access drops what getRawFirstPart() returns. A caller that
41 // can change the parts must not be handed bytes that claim to be the
42 // ones that arrived.
43 //
44 // Assigning a fresh Data rather than calling clear() on the old one:
45 // Data::clear() only sets the size to zero and deliberately keeps the
46 // shared pointer, so "empty" and "points nowhere" would otherwise be two
47 // different states.
48 Parts& parts() {checkParsed(); mRawFirstPart = Data(); return mContents;}
49 const Parts& parts() const {checkParsed(); return mContents;}
50
80 Data getRawFirstPart() const;
81
82 void setBoundary(const Data& boundary);
83
90 static constexpr unsigned int MaxNestingDepth = 32;
91
96 class Exception final : public BaseException
97 {
98 public:
99 Exception(const Data& msg, const Data& file, const int line)
100 : BaseException(msg, file, line) {}
101
102 const char* name() const noexcept override { return "MultipartMixedContents::Exception"; }
103 };
104
105 static bool init();
106
107 protected:
108 void clear();
109
110 private:
111 void setBoundary();
112 std::vector<Contents*> mContents;
113 // A read-only view of the first part inside the buffer this object was
114 // parsed from, not a copy of it. Empty unless this object was parsed,
115 // see getRawFirstPart().
116 Data mRawFirstPart;
117 // Multipart levels above this one: 0 for the outermost body. parse()
118 // stamps each multipart part it creates with its own depth + 1, so the
119 // limit holds however late, and by whom, a nested part is parsed.
120 unsigned int mDepth;
121};
122
124
125}
126
127#endif
128
129/* ====================================================================
130 * The Vovida Software License, Version 1.0
131 *
132 * Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
133 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
134 *
135 * Redistribution and use in source and binary forms, with or without
136 * modification, are permitted provided that the following conditions
137 * are met:
138 *
139 * 1. Redistributions of source code must retain the above copyright
140 * notice, this list of conditions and the following disclaimer.
141 *
142 * 2. Redistributions in binary form must reproduce the above copyright
143 * notice, this list of conditions and the following disclaimer in
144 * the documentation and/or other materials provided with the
145 * distribution.
146 *
147 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
148 * and "Vovida Open Communication Application Library (VOCAL)" must
149 * not be used to endorse or promote products derived from this
150 * software without prior written permission. For written
151 * permission, please contact vocal@vovida.org.
152 *
153 * 4. Products derived from this software may not be called "VOCAL", nor
154 * may "VOCAL" appear in their name, without prior written
155 * permission of Vovida Networks, Inc.
156 *
157 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
158 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
159 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
160 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
161 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
162 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
163 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
164 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
165 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
166 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
167 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
168 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
169 * DAMAGE.
170 *
171 * ====================================================================
172 *
173 * This software consists of voluntary contributions made by Vovida
174 * Networks, Inc. and many individuals on behalf of Vovida Networks,
175 * Inc. For more information on Vovida Networks, Inc., please see
176 * <http://www.vovida.org/>.
177 *
178 */
The abstract base-class for all exceptions thrown by resip code.
Base class for all SIP body types.
Definition Contents.hxx:51
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
void checkParsed() const
Represents the "media-type" element in the RFC 3261 grammar.
Definition Mime.hxx:20
Thrown when there is an error parsing a multi-part mixed contents envelope.
Exception(const Data &msg, const Data &file, const int line)
const char * name() const noexcept override
SIP body type for holding Multipart-Mixed body contents (MIME content-type multipart/mixed).
static constexpr unsigned int MaxNestingDepth
parse() fails (Exception) a body nested more than this many multipart levels below the outermost one.
Data getRawFirstPart() const
The first body part exactly as it arrived: header block, the empty line, and the body.
virtual Contents * clone() const
duplicate an MultipartMixedContents object
virtual void parse(ParseBuffer &pb)
virtual EncodeStream & encodeParsed(EncodeStream &str) const
MultipartMixedContents & operator=(const MultipartMixedContents &rhs)
Provides string-parsing functionality with protection from buffer overflow.
dcm! – add UnusedChecking(_enum) below;
static bool invokeMultipartMixedContentsInit
#define EncodeStream