Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
runcon
Plantuml Server
Commits
4c845a5d
Commit
4c845a5d
authored
Dec 02, 2013
by
Maxime Sinclair
Browse files
[FEATURE] Proxy returns the correct Content-type
parent
b9d71300
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/net/sourceforge/plantuml/servlet/ProxyServlet.java
View file @
4c845a5d
...
...
@@ -35,12 +35,16 @@ import javax.servlet.http.HttpServlet;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
net.sourceforge.plantuml.BlockUml
;
import
net.sourceforge.plantuml.FileFormat
;
import
net.sourceforge.plantuml.FileFormatOption
;
import
net.sourceforge.plantuml.SourceStringReader
;
import
net.sourceforge.plantuml.core.Diagram
;
import
net.sourceforge.plantuml.core.UmlSource
;
import
java.security.cert.Certificate
;
import
java.util.List
;
import
javax.imageio.IIOException
;
import
javax.net.ssl.HttpsURLConnection
;
import
javax.net.ssl.SSLPeerUnverifiedException
;
...
...
@@ -73,8 +77,22 @@ public class ProxyServlet extends HttpServlet {
System
.
out
.
println
(
"getSource=>"
+
diagmarkup
);
SourceStringReader
reader
=
new
SourceStringReader
(
diagmarkup
);
int
n
=
index
==
null
?
0
:
Integer
.
parseInt
(
index
);
reader
.
generateImage
(
response
.
getOutputStream
(),
n
,
new
FileFormatOption
(
getOutputFormat
(),
false
));
List
<
BlockUml
>
blocks
=
reader
.
getBlocks
();
BlockUml
block
=
blocks
.
get
(
n
);
Diagram
diagram
=
block
.
getDiagram
();
UmlSource
umlSrc
=
diagram
.
getSource
();
String
uml
=
umlSrc
.
getPlainString
();
System
.
out
.
println
(
"uml="
+
uml
);
// generate the response
DiagramResponse
dr
=
new
DiagramResponse
(
response
,
getOutputFormat
());
try
{
dr
.
sendDiagram
(
uml
);
}
catch
(
IIOException
iioe
)
{
// Browser has closed the connection, so the HTTP OutputStream is closed
// Silently catch the exception to avoid annoying log
}
dr
=
null
;
}
private
String
getSource
(
URL
url
)
throws
IOException
{
...
...
src/test/java/net/sourceforge/plantuml/servlet/TestProxy.java
View file @
4c845a5d
...
...
@@ -19,7 +19,7 @@ public class TestProxy extends WebappTestCase {
WebResponse
response
=
conversation
.
getResource
(
request
);
// Analyze response
// Verifies the Content-Type header
//
assertEquals( "Response content type is not PNG", "image/png", response.getContentType());
assertEquals
(
"Response content type is not PNG"
,
"image/png"
,
response
.
getContentType
());
// Get the image and verify its size (~2000 bytes)
InputStream
responseStream
=
response
.
getInputStream
();
ByteArrayOutputStream
imageStream
=
new
ByteArrayOutputStream
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment