Skip to content

Commit

Permalink
Fixed incorrect content length causing invalid JSON response
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenvh1 committed Nov 13, 2016
1 parent 8ae6100 commit ce3bbf3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
8 changes: 4 additions & 4 deletions server/ETS2 Local Radio desktop/SimpleServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,19 @@ private void Process(HttpListenerContext context)
string text = Newtonsoft.Json.JsonConvert.SerializeObject(Main.ets2data);

context.Response.ContentType = "application/json";
context.Response.ContentLength64 = text.Length;
context.Response.ContentLength64 = Encoding.UTF8.GetBytes(text).Length;
context.Response.StatusCode = (int)HttpStatusCode.OK;
context.Response.OutputStream.Write(Encoding.UTF8.GetBytes(text), 0, text.Length);
context.Response.OutputStream.Write(Encoding.UTF8.GetBytes(text), 0, Encoding.UTF8.GetBytes(text).Length);
context.Response.OutputStream.Flush();
}
else if (context.Request.Url.AbsolutePath == "/commands/")
{
string text = Newtonsoft.Json.JsonConvert.SerializeObject(Main.commandsData);

context.Response.ContentType = "application/json";
context.Response.ContentLength64 = text.Length;
context.Response.ContentLength64 = Encoding.UTF8.GetBytes(text).Length;
context.Response.StatusCode = (int)HttpStatusCode.OK;
context.Response.OutputStream.Write(Encoding.UTF8.GetBytes(text), 0, text.Length);
context.Response.OutputStream.Write(Encoding.UTF8.GetBytes(text), 0, Encoding.UTF8.GetBytes(text).Length);
context.Response.OutputStream.Flush();
}
else if (File.Exists(filename))
Expand Down
12 changes: 1 addition & 11 deletions web/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//current version:
var version = "0.4.0";
var version = "0.4.1";
//countries near you global:
var g_countries = {};
//stations near you global:
Expand All @@ -20,8 +20,6 @@ var g_hls = null;
var g_last_command = "0";

function initialise() {
$(document).ready(function () {

document.getElementById("switchStation").volume = 0;

//Check updates:
Expand Down Expand Up @@ -59,14 +57,6 @@ function initialise() {
localStorage.setItem("volume", g_volume);
}
});

$(".thumb").hover(function () {
this.append("<div class='play-button'></div>")
},
function () {

});
});
}

function refresh(data) {
Expand Down
5 changes: 2 additions & 3 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
<!-- Collect the nav links, forms, and other content for toggling -->
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="javascript:window.history.back();">Back</a></li>
<li><a href="#" data-toggle="modal" data-target="#connectModal">Connect to other device</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
Expand All @@ -73,9 +72,9 @@ <h1 class="text-center">Stations:</h1>
</div>
<div class="row">
<div class="col-lg-12">
<div class="alert alert-info update">An update is available! <a class="btn btn-xs btn-primary" href="https://github.com/Koenvh1/ets2-local-radio/releases">Update now</a> </div>
<div class="alert alert-info update">An update is available! <a class="btn btn-xs btn-default" href="https://github.com/Koenvh1/ets2-local-radio/releases">Update now</a> </div>
<!--div class="alert alert-primary statusMessage"></div-->
<div class="alert remote">This player is being controlled remotely</div>
<div class="alert alert-primary remote">This player is being controlled remotely</div>
<p><a href="http://koenvh.nl/submit-station" target="_blank" class="btn btn-xs btn-primary">Submit a new station</a><span class="label label-primary label-id">This device: <span class="peer-id"></span></span></p>
</div>
</div>
Expand Down

0 comments on commit ce3bbf3

Please sign in to comment.