Skip to content

Commit

Permalink
fix for #335
Browse files Browse the repository at this point in the history
  • Loading branch information
rikdpp committed Nov 4, 2014
1 parent 62ac93f commit 1de4b10
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ public ProxyStreamServlet() {
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String origin = request.getParameter("origin");
String authorization = request.getParameter("authorization");
if (origin == null) {
response.setStatus(500);
response.getWriter().println("Required parameter 'origin' missing. Example: 107.20.175.135:7001");
return;
}
origin = origin.trim();

HttpGet httpget = null;
InputStream is = null;
boolean hasFirstParameter = false;
Expand All @@ -60,7 +61,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
@SuppressWarnings("unchecked")
Map<String, String[]> params = request.getParameterMap();
for (String key : params.keySet()) {
if (!key.equals("origin")) {
if (!key.equals("origin") && !key.equals("authorization")) {
String[] values = params.get(key);
String value = values[0].trim();
if (hasFirstParameter) {
Expand All @@ -76,6 +77,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
logger.info("\n\nProxy opening connection to: " + proxyUrl + "\n\n");
try {
httpget = new HttpGet(proxyUrl);
if (authorization != null) {
httpget.addHeader("Authorization", authorization);
}
HttpClient client = ProxyConnectionManager.httpClient;
HttpResponse httpResponse = client.execute(httpget);
int statusCode = httpResponse.getStatusLine().getStatusCode();
Expand Down
6 changes: 5 additions & 1 deletion hystrix-dashboard/src/main/webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
if($('#title').val().length > 0) {
url += "&title=" + encodeURIComponent($('#title').val());
}
if($('#authorization').val().length > 0) {
url += "&authorization=" + encodeURIComponent($('#authorization').val());
}
location.href= url;
} else {
$('#message').html("The 'stream' value is required.");
Expand All @@ -44,7 +47,8 @@ <h2>Hystrix Dashboard</h2>
<br><br>
Delay: <input id="delay" type="textfield" size="10" placeholder="2000"></input>ms
&nbsp;&nbsp;&nbsp;&nbsp;
Title: <input id="title" type="textfield" size="60" placeholder="Example Hystrix App"></input><br>
Title: <input id="title" type="textfield" size="60" placeholder="Example Hystrix App"></input><br><br>
Authorization: <input id="authorization" type="textfield" size="60" placeholder="Basic Zm9vOmJhcg=="></input><br>
<br>
<button onclick="sendToMonitor()">Monitor Stream</button>
<br><br>
Expand Down
13 changes: 9 additions & 4 deletions hystrix-dashboard/src/main/webapp/monitor/monitor.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,20 @@ <h2><span id="title_name"></span></h2>
if(getUrlVars()["delay"] != undefined) {
stream = stream + "&delay=" + getUrlVars()["delay"];
}

var commandStream = "../proxy.stream?origin=" + stream;
var poolStream = "../proxy.stream?origin=" + stream;


if(getUrlVars()["title"] != undefined) {
$('#title_name').html("Hystrix Stream: " + decodeURIComponent(getUrlVars()["title"]))
} else {
$('#title_name').html("Hystrix Stream: " + decodeURIComponent(stream))
}

//do not show authorization in stream title
if(getUrlVars()["authorization"] != undefined) {
stream = stream + "&authorization=" + getUrlVars()["authorization"];
}

var commandStream = "../proxy.stream?origin=" + stream;
var poolStream = "../proxy.stream?origin=" + stream;
}

$(window).load(function() { // within load with a setTimeout to prevent the infinite spinner
Expand Down

0 comments on commit 1de4b10

Please sign in to comment.