Skip to content

Commit

Permalink
Make sure POSTS that fail are immediately cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
jhy committed Jul 11, 2021
1 parent e62a447 commit 78f4289
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ jsoup changelog

*** Release 1.14.2 [PENDING]
* Bugfix: corrected a potential case of the parser input stream not being closed immediately on a read exception.


* Bugfix: when making a HTTP POST, if the request write fails, make sure the connection is immediately cleaned up.

* Bugfix [Fuzz]: fixed a slow parse when a tag has thousands of null characters in it.
<https://github.com/jhy/jsoup/issues/1580>

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/jsoup/helper/HttpConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,10 @@ else if (methodHasBody)
Response res = null;
try {
conn.connect();
if (conn.getDoOutput())
writePost(req, conn.getOutputStream(), mimeBoundary);
if (conn.getDoOutput()) {
try { writePost(req, conn.getOutputStream(), mimeBoundary); }
catch (IOException e) { conn.disconnect(); throw e; }
}

int status = conn.getResponseCode();
res = new Response(conn, req, previousResponse);
Expand Down

0 comments on commit 78f4289

Please sign in to comment.