Skip to content

Commit

Permalink
KTOR-325 - update MultiPartFormDataContent to allow contentType overr…
Browse files Browse the repository at this point in the history
…ide using optional builder (#2003)

* allow contentType override using optional builder

* move boundary and contentType to MultiPartFormDataContent ctor
  • Loading branch information
jschneidereit committed Nov 23, 2021
1 parent 240363d commit e1270e9
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ public class FormDataContent(
* @param parts: form part data
*/
public class MultiPartFormDataContent(
parts: List<PartData>
parts: List<PartData>,
val boundary: String = generateBoundary(),
override val contentType: ContentType = ContentType.MultiPart.Mixed.withParameter("boundary", boundary)
) : OutgoingContent.WriteChannelContent() {
private val boundary: String = generateBoundary()
private val BOUNDARY_BYTES = "--$boundary\r\n".toByteArray()
private val LAST_BOUNDARY_BYTES = "--$boundary--\r\n".toByteArray()

Expand Down Expand Up @@ -82,8 +83,6 @@ public class MultiPartFormDataContent(

override val contentLength: Long?

override val contentType: ContentType = ContentType.MultiPart.FormData.withParameter("boundary", boundary)

init {
var rawLength: Long? = 0
for (part in rawParts) {
Expand Down

0 comments on commit e1270e9

Please sign in to comment.