Skip to content

Commit

Permalink
bump wiki.java
Browse files Browse the repository at this point in the history
to resolve http upload error
  • Loading branch information
Abbe98 committed Jan 23, 2022
1 parent c1f8d02 commit 956dd86
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/org/wikipedia/Wiki.java
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,24 @@ public Map<String, Integer> getSiteStatistics() throws IOException
ret.put("jobs", Integer.parseInt(parseAttribute(text, "jobs", 0))); // job queue length
return ret;
}

/**
* Require the given extension be installed on this wiki, or throw an
* UnsupportedOperationException if it isn't.
* @param extension the name of the extension to check
* @throws UnsupportedOperationException if that extension is not
* installed on this wiki
* @throws UncheckedIOException if the site info cache is not populated
* and a network error occurs when populating it
* @since 0.37
*/
public void requiresExtension(String extension)
{
if (!installedExtensions().contains(extension))
throw new UnsupportedOperationException("Extension \"" + extension
+ "\" is not installed on " + getDomain() + ". "
+ "Please check the extension name and [[Special:Version]].");
}

/**
* Renders the specified wiki markup as HTML by passing it to the MediaWiki
Expand Down Expand Up @@ -8110,7 +8128,7 @@ public String makeApiCall(Map<String, String> getparams, Map<String, Object> pos
boolean isPOST = (postparams != null && !postparams.isEmpty());
StringBuilder stringPostBody = new StringBuilder();
boolean multipart = false;
ArrayList<byte[]> multipartPostBody = new ArrayList<>();
ByteArrayOutputStream multipartPostBody = new ByteArrayOutputStream();
String boundary = "----------NEXT PART----------";
if (isPOST)
{
Expand All @@ -8132,18 +8150,18 @@ public String makeApiCall(Map<String, String> getparams, Map<String, Object> pos
for (Map.Entry<String, ?> entry : postparams.entrySet())
{
Object value = entry.getValue();
multipartPostBody.add((nextpart + entry.getKey() + "\"").getBytes(StandardCharsets.UTF_8));
multipartPostBody.write((nextpart + entry.getKey() + "\"").getBytes(StandardCharsets.UTF_8));
if (value instanceof String)
multipartPostBody.add(("Content-Type: text/plain; charset=UTF-8\r\n\r\n" + (String)value + "\r\n")
multipartPostBody.write(("Content-Type: text/plain; charset=UTF-8\r\n\r\n" + (String)value + "\r\n")
.getBytes(StandardCharsets.UTF_8));
else if (value instanceof byte[])
{
multipartPostBody.add("Content-Type: application/octet-stream\r\n\r\n".getBytes(StandardCharsets.UTF_8));
multipartPostBody.add((byte[])value);
multipartPostBody.add("\r\n".getBytes(StandardCharsets.UTF_8));
multipartPostBody.write("Content-Type: application/octet-stream\r\n\r\n".getBytes(StandardCharsets.UTF_8));
multipartPostBody.write((byte[])value);
multipartPostBody.write("\r\n".getBytes(StandardCharsets.UTF_8));
}
}
multipartPostBody.add((boundary + "--\r\n").getBytes(StandardCharsets.UTF_8));
multipartPostBody.write((boundary + "--\r\n").getBytes(StandardCharsets.UTF_8));
}
else
{
Expand Down Expand Up @@ -8171,7 +8189,7 @@ else if (value instanceof byte[])
if (isPOST)
{
if (multipart)
connection = connection.POST(HttpRequest.BodyPublishers.ofByteArrays(multipartPostBody))
connection = connection.POST(HttpRequest.BodyPublishers.ofByteArray(multipartPostBody.toByteArray()))
.header("Content-Type", "multipart/form-data; boundary=" + boundary);
else
connection = connection.POST(HttpRequest.BodyPublishers.ofString(stringPostBody.toString()))
Expand Down

0 comments on commit 956dd86

Please sign in to comment.