Skip to content

Commit 2d66c8e

Browse files
committed
(GH-95) Use optional parameters in StreamingMultipartFormDataParser constructor
1 parent eb739ec commit 2d66c8e

1 file changed

Lines changed: 7 additions & 92 deletions

File tree

Source/HttpMultipartParser/StreamingMultipartFormDataParser.cs

Lines changed: 7 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -101,110 +101,25 @@ public class StreamingMultipartFormDataParser
101101

102102
#region Constructors and Destructors
103103

104-
/// <summary>
105-
/// Initializes a new instance of the <see cref="StreamingMultipartFormDataParser" /> class
106-
/// with an input stream. Boundary will be automatically detected based on the
107-
/// first line of input.
108-
/// </summary>
109-
/// <param name="stream">
110-
/// The stream containing the multipart data.
111-
/// </param>
112-
public StreamingMultipartFormDataParser(Stream stream)
113-
: this(stream, null, Encoding.UTF8, DefaultBufferSize, null)
114-
{
115-
}
116-
117-
/// <summary>
118-
/// Initializes a new instance of the <see cref="StreamingMultipartFormDataParser" /> class
119-
/// with the boundary and input stream.
120-
/// </summary>
121-
/// <param name="stream">
122-
/// The stream containing the multipart data.
123-
/// </param>
124-
/// <param name="boundary">
125-
/// The multipart/form-data boundary. This should be the value
126-
/// returned by the request header.
127-
/// </param>
128-
public StreamingMultipartFormDataParser(Stream stream, string boundary)
129-
: this(stream, boundary, Encoding.UTF8, DefaultBufferSize, null)
130-
{
131-
}
132-
133-
/// <summary>
134-
/// Initializes a new instance of the <see cref="StreamingMultipartFormDataParser" /> class
135-
/// with the input stream and stream encoding. Boundary is automatically
136-
/// detected.
137-
/// </summary>
138-
/// <param name="stream">
139-
/// The stream containing the multipart data.
140-
/// </param>
141-
/// <param name="encoding">
142-
/// The encoding of the multipart data.
143-
/// </param>
144-
public StreamingMultipartFormDataParser(Stream stream, Encoding encoding)
145-
: this(stream, null, encoding, DefaultBufferSize, null)
146-
{
147-
}
148-
149-
/// <summary>
150-
/// Initializes a new instance of the <see cref="StreamingMultipartFormDataParser" /> class
151-
/// with the boundary, input stream and stream encoding.
152-
/// </summary>
153-
/// <param name="stream">
154-
/// The stream containing the multipart data.
155-
/// </param>
156-
/// <param name="boundary">
157-
/// The multipart/form-data boundary. This should be the value
158-
/// returned by the request header.
159-
/// </param>
160-
/// <param name="encoding">
161-
/// The encoding of the multipart data.
162-
/// </param>
163-
public StreamingMultipartFormDataParser(Stream stream, string boundary, Encoding encoding)
164-
: this(stream, boundary, encoding, DefaultBufferSize, null)
165-
{
166-
}
167-
168-
/// <summary>
169-
/// Initializes a new instance of the <see cref="StreamingMultipartFormDataParser" /> class
170-
/// with the stream, input encoding and buffer size. Boundary is automatically
171-
/// detected.
172-
/// </summary>
173-
/// <param name="stream">
174-
/// The stream containing the multipart data.
175-
/// </param>
176-
/// <param name="encoding">
177-
/// The encoding of the multipart data.
178-
/// </param>
179-
/// <param name="binaryBufferSize">
180-
/// The size of the buffer to use for parsing the multipart form data. This must be larger
181-
/// then (size of boundary + 4 + # bytes in newline).
182-
/// </param>
183-
public StreamingMultipartFormDataParser(Stream stream, Encoding encoding, int binaryBufferSize)
184-
: this(stream, null, encoding, binaryBufferSize, null)
185-
{
186-
}
187-
188104
/// <summary>
189105
/// Initializes a new instance of the <see cref="StreamingMultipartFormDataParser" /> class
190106
/// with the boundary, stream, input encoding and buffer size.
191107
/// </summary>
192108
/// <param name="stream">
193109
/// The stream containing the multipart data.
194110
/// </param>
195-
/// <param name="boundary">
196-
/// The multipart/form-data boundary. This should be the value
197-
/// returned by the request header.
198-
/// </param>
199111
/// <param name="encoding">
200112
/// The encoding of the multipart data.
201113
/// </param>
202114
/// <param name="binaryBufferSize">
203115
/// The size of the buffer to use for parsing the multipart form data. This must be larger
204116
/// then (size of boundary + 4 + # bytes in newline).
205117
/// </param>
206-
public StreamingMultipartFormDataParser(Stream stream, string boundary, Encoding encoding, int binaryBufferSize)
207-
: this(stream, boundary, encoding, binaryBufferSize, null)
118+
/// <param name="binaryMimeTypes">
119+
/// List of mimetypes that should be detected as file.
120+
/// </param>
121+
public StreamingMultipartFormDataParser(Stream stream, Encoding encoding, int binaryBufferSize = DefaultBufferSize, string[] binaryMimeTypes = null)
122+
: this(stream, null, encoding, binaryBufferSize, binaryMimeTypes)
208123
{
209124
}
210125

@@ -229,13 +144,13 @@ public StreamingMultipartFormDataParser(Stream stream, string boundary, Encoding
229144
/// <param name="binaryMimeTypes">
230145
/// List of mimetypes that should be detected as file.
231146
/// </param>
232-
public StreamingMultipartFormDataParser(Stream stream, string boundary, Encoding encoding, int binaryBufferSize, string[] binaryMimeTypes)
147+
public StreamingMultipartFormDataParser(Stream stream, string boundary = null, Encoding encoding = null, int binaryBufferSize = DefaultBufferSize, string[] binaryMimeTypes = null)
233148
{
234149
if (stream == null || stream == Stream.Null) { throw new ArgumentNullException("stream"); }
235150

236151
this.stream = stream;
237152
this.boundary = boundary;
238-
Encoding = encoding ?? throw new ArgumentNullException("encoding");
153+
Encoding = encoding ?? Encoding.UTF8;
239154
BinaryBufferSize = binaryBufferSize;
240155
readEndBoundary = false;
241156
if (binaryMimeTypes != null)

0 commit comments

Comments
 (0)