Add POST support
This commit is contained in:
@@ -23,17 +23,18 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.servlet.utility.UmlExtractor;
|
||||
|
||||
import javax.imageio.IIOException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.servlet.utility.UmlExtractor;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Common service servlet to produce diagram from compressed UML source contained in the end part of the requested URI.
|
||||
@@ -59,7 +60,36 @@ public abstract class UmlDiagramService extends HttpServlet {
|
||||
DiagramResponse dr = new DiagramResponse(response, getOutputFormat(), request);
|
||||
final int idx = Integer.parseInt(sourceAndIdx[1]);
|
||||
try {
|
||||
dr.sendDiagram(uml, idx);
|
||||
dr.sendDiagram(uml, idx, false);
|
||||
} catch (IIOException iioe) {
|
||||
// Browser has closed the connection, so the HTTP OutputStream is closed
|
||||
// Silently catch the exception to avoid annoying log
|
||||
}
|
||||
dr = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
|
||||
// build the UML source from the compressed request parameter
|
||||
final String[] sourceAndIdx = getSourceAndIdx(request);
|
||||
// final String uml;
|
||||
|
||||
final StringBuilder uml = new StringBuilder();
|
||||
final BufferedReader in = request.getReader();
|
||||
while (true) {
|
||||
final String line = in.readLine();
|
||||
if (line == null) {
|
||||
break;
|
||||
}
|
||||
uml.append(line).append('\n');
|
||||
}
|
||||
|
||||
// generate the response
|
||||
DiagramResponse dr = new DiagramResponse(response, getOutputFormat(), request);
|
||||
final int idx = Integer.parseInt(sourceAndIdx[1]);
|
||||
try {
|
||||
dr.sendDiagram(uml.toString(), idx, true);
|
||||
} catch (IIOException iioe) {
|
||||
// Browser has closed the connection, so the HTTP OutputStream is closed
|
||||
// Silently catch the exception to avoid annoying log
|
||||
|
||||
Reference in New Issue
Block a user