11/*
2- * Copyright 2014-2016 the original author or authors.
2+ * Copyright 2014-2017 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -158,12 +158,12 @@ private void writeParts(OperationRequest request, PrintWriter writer) {
158158 for (Entry <String , List <String >> parameter : request .getParameters ().entrySet ()) {
159159 if (parameter .getValue ().isEmpty ()) {
160160 writePartBoundary (writer );
161- writePart (parameter .getKey (), "" , null , writer );
161+ writePart (parameter .getKey (), "" , null , null , writer );
162162 }
163163 else {
164164 for (String value : parameter .getValue ()) {
165165 writePartBoundary (writer );
166- writePart (parameter .getKey (), value , null , writer );
166+ writePart (parameter .getKey (), value , null , null , writer );
167167 writer .println ();
168168 }
169169 }
@@ -181,13 +181,17 @@ private void writePartBoundary(PrintWriter writer) {
181181 }
182182
183183 private void writePart (OperationRequestPart part , PrintWriter writer ) {
184- writePart (part .getName (), part .getContentAsString (),
184+ writePart (part .getName (), part .getContentAsString (), part . getSubmittedFileName (),
185185 part .getHeaders ().getContentType (), writer );
186186 }
187187
188- private void writePart (String name , String value , MediaType contentType ,
189- PrintWriter writer ) {
190- writer .printf ("Content-Disposition: form-data; name=%s%n" , name );
188+ private void writePart (String name , String value , String filename ,
189+ MediaType contentType , PrintWriter writer ) {
190+ writer .printf ("Content-Disposition: form-data; name=%s" , name );
191+ if (StringUtils .hasText (filename )) {
192+ writer .printf ("; filename=%s" , filename );
193+ }
194+ writer .printf ("%n" );
191195 if (contentType != null ) {
192196 writer .printf ("Content-Type: %s%n" , contentType );
193197 }
0 commit comments