Polish contribution

See gh-31757
This commit is contained in:
Sam Brannen
2023-12-05 16:07:21 +01:00
parent a596c0e226
commit db48813181
3 changed files with 19 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,24 +63,21 @@ public class MockPart implements Part {
* @see #getHeaders()
*/
public MockPart(String name, @Nullable String filename, @Nullable byte[] content) {
Assert.hasLength(name, "'name' must not be empty");
this.name = name;
this.filename = filename;
this.content = (content != null ? content : new byte[0]);
this.headers.setContentDispositionFormData(name, filename);
this(name, filename, content, null);
}
/**
* Constructor for a part with a filename, byte[] content and MediaType mediaType.
* Constructor for a part with a filename, byte[] content, and content type.
* @since 6.1.2
* @see #getHeaders()
*/
public MockPart(String name, @Nullable String filename, @Nullable byte[] content, @Nullable MediaType mediaType) {
public MockPart(String name, @Nullable String filename, @Nullable byte[] content, @Nullable MediaType contentType) {
Assert.hasLength(name, "'name' must not be empty");
this.name = name;
this.filename = filename;
this.content = (content != null ? content : new byte[0]);
this.headers.setContentDispositionFormData(name, filename);
this.headers.setContentType(mediaType);
this.headers.setContentType(contentType);
}