Index: core/matchers/build.gradle IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/core/matchers/build.gradle b/core/matchers/build.gradle --- a/core/matchers/build.gradle (revision 2fdaf2795359def73743a308bb8544529757a240) +++ b/core/matchers/build.gradle (date 1624139540105) @@ -7,6 +7,7 @@ implementation "org.slf4j:slf4j-api:${project.slf4jVersion}" implementation 'org.atteo:evo-inflector:1.2.2' implementation 'com.github.ajalt:mordant:1.2.1' + implementation("com.squareup.okhttp3:okhttp:4.9.0") testRuntime "ch.qos.logback:logback-classic:${project.logbackVersion}" testRuntime "org.junit.vintage:junit-vintage-engine:${project.junit5Version}" Index: consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/PactDslRequestBase.kt IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/PactDslRequestBase.kt b/consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/PactDslRequestBase.kt --- a/consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/PactDslRequestBase.kt (revision 2fdaf2795359def73743a308bb8544529757a240) +++ b/consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/PactDslRequestBase.kt (date 1624208446272) @@ -16,12 +16,12 @@ import au.com.dius.pact.core.model.matchingrules.TimeMatcher import au.com.dius.pact.core.model.matchingrules.TimestampMatcher import au.com.dius.pact.core.support.isNotEmpty +import okhttp3.MediaType.Companion.toMediaTypeOrNull +import okhttp3.MultipartBody +import okhttp3.RequestBody.Companion.toRequestBody +import okio.Buffer import org.apache.commons.lang3.StringUtils import org.apache.commons.lang3.time.FastDateFormat -import org.apache.http.entity.ContentType -import org.apache.http.entity.mime.HttpMultipartMode -import org.apache.http.entity.mime.MultipartEntityBuilder -import java.io.ByteArrayOutputStream import java.io.IOException import java.util.Date @@ -58,17 +58,18 @@ @Throws(IOException::class) protected fun setupFileUpload(partName: String?, fileName: String?, fileContentType: String?, data: ByteArray?) { - val multipart = MultipartEntityBuilder.create() - .setMode(HttpMultipartMode.BROWSER_COMPATIBLE) - .addBinaryBody(partName, data, ContentType.create(fileContentType), fileName) + val multipart = MultipartBody.Builder() + .setType(MultipartBody.FORM) + .addFormDataPart(partName!!, fileName!!, + data!!.toRequestBody(fileContentType!!.toMediaTypeOrNull())) .build() - val os = ByteArrayOutputStream() - multipart.writeTo(os) - requestBody = body(os.toByteArray(), - au.com.dius.pact.core.model.ContentType(multipart.contentType.value)) + val buffer = Buffer() + multipart.writeTo(buffer) + requestBody = body(buffer.readByteString().toByteArray(), + au.com.dius.pact.core.model.ContentType(multipart.contentType().toString())) requestMatchers.addCategory("header").addRule(CONTENT_TYPE, RegexMatcher(MULTIPART_HEADER_REGEX, - multipart.contentType.value)) - requestHeaders[CONTENT_TYPE] = listOf(multipart.contentType.value) + multipart.contentType().toString())) + requestHeaders[CONTENT_TYPE] = listOf(multipart.contentType().toString()) } protected fun queryMatchingDateBase(field: String, pattern: String?, example: String?): PactDslRequestBase {