kwin commented on code in PR #1798:
URL: https://github.com/apache/maven-resolver/pull/1798#discussion_r2817267626


##########
maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk11/src/main/java/org/eclipse/aether/transport/jdk/JdkTransporter.java:
##########
@@ -397,14 +397,20 @@ protected void implPut(PutTask task) throws Exception {
         }
         headers.forEach(request::setHeader);
 
-        request.PUT(HttpRequest.BodyPublishers.ofInputStream(() -> {
-            try {
-                return new TransportListenerNotifyingInputStream(
-                        task.newInputStream(), task.getListener(), 
task.getDataLength());
-            } catch (IOException e) {
-                throw new UncheckedIOException(e);
-            }
-        }));
+        if (task.getDataLength() == 0L) {
+            request.PUT(HttpRequest.BodyPublishers.noBody());
+        } else {
+            request.PUT(HttpRequest.BodyPublishers.fromPublisher(
+                    HttpRequest.BodyPublishers.ofInputStream(() -> {
+                        try {
+                            return new TransportListenerNotifyingInputStream(
+                                    task.newInputStream(), task.getListener(), 
task.getDataLength());
+                        } catch (IOException e) {
+                            throw new UncheckedIOException(e);
+                        }
+                    }),
+                    task.getDataLength()));

Review Comment:
   ```suggestion
                      // this adds a content-length request header
                       task.getDataLength()));
   ```
   because that is probably not obvious



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to