File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
api/src/main/java/org/asynchttpclient/multipart Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,8 @@ enum FileLocation {
55
55
}
56
56
57
57
public MultipartBody (List <Part > parts , String contentType , long contentLength ) {
58
- this .boundary = MultipartEncodingUtil .getAsciiBytes (contentType .substring (contentType .indexOf ("boundary=" ) + "boundary=" .length ()));
58
+ this .boundary = MultipartEncodingUtil .getAsciiBytes (contentType .substring (contentType .indexOf ("boundary=" )
59
+ + "boundary=" .length ()));
59
60
this .contentLength = contentLength ;
60
61
this .parts = parts ;
61
62
}
@@ -113,14 +114,19 @@ public long read(ByteBuffer buffer) throws IOException {
113
114
startPart ++;
114
115
115
116
} else if (part instanceof AbstractFilePart ) {
116
- if (fileLocation == FileLocation .NONE ) {
117
+
118
+ switch (fileLocation ) {
119
+ case NONE :
117
120
currentFilePart = (AbstractFilePart ) part ;
118
121
initializeFilePart (currentFilePart );
119
- } else if (fileLocation == FileLocation .START ) {
122
+ break ;
123
+ case START :
120
124
initializeFileBody (currentFilePart );
121
- } else if (fileLocation == FileLocation .MIDDLE ) {
125
+ break ;
126
+ case MIDDLE :
122
127
initializeFileEnd (currentFilePart );
123
- } else if (fileLocation == FileLocation .END ) {
128
+ break ;
129
+ case END :
124
130
startPart ++;
125
131
fileLocation = FileLocation .NONE ;
126
132
if (startPart == parts .size () && currentStream .available () == 0 ) {
You can’t perform that action at this time.
0 commit comments