Skip to content

Commit

Permalink
TROPO-12171
Browse files Browse the repository at this point in the history
deal with the backslash in header's value
  • Loading branch information
frankmeten committed Aug 29, 2017
1 parent 93b1069 commit 1745973
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
4 changes: 3 additions & 1 deletion TropoCSharp/TropoJSON.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public static void RenderJSON(this Tropo tropo, HttpResponse response)
tropo.Voice = null;
JsonSerializerSettings settings = new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore };
response.AddHeader("WebAPI-Lang-Ver", "CSharp V15.9.0 SNAPSHOT");
response.Write(JsonConvert.SerializeObject(tropo, Formatting.None, settings).Replace("\\", "").Replace("\"{", "{").Replace("}\"", "}"));
string sorig = JsonConvert.SerializeObject(tropo, Formatting.None, settings);
string s = sorig.Replace("\\\"", "\"").Replace("\\\\", "\\").Replace("\"{", "{").Replace("}\"", "}");
response.Write(s);

}
}
Expand Down
2 changes: 1 addition & 1 deletion TropoClassesTests/TropoClassesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ private string renderJSONToText(Tropo tropo)
tropo.Language = null;
tropo.Voice = null;
JsonSerializerSettings settings = new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore };
return JsonConvert.SerializeObject(tropo, Formatting.None, settings).Replace("\\", "").Replace("\"{", "{").Replace("}\"", "}");
return JsonConvert.SerializeObject(tropo, Formatting.None, settings).Replace("\\\"", "\"").Replace("\\\\", "\\").Replace("\"{", "{").Replace("}\"", "}");
}

}
Expand Down
2 changes: 2 additions & 0 deletions TropoSample/TROPO12171.aspx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TROPO12171.aspx.cs" Inherits="TropoSample.TROPO12171" %>

34 changes: 34 additions & 0 deletions TropoSample/TROPO12171.aspx.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Web.UI;
using TropoCSharp.Structs;
using TropoCSharp.Tropo;

namespace TropoSample
{
/// <summary>
/// A simple example demonstrating how to use the Ask method.
/// </summary>
public partial class TROPO12171 : Page
{
public void Page_Load(object sender, EventArgs args)
{
// Create a new instance of the Tropo object.
Tropo tropo = new Tropo();

Say say1 = new Say("test remote party id 3");

IDictionary<string, string> headers = new Dictionary<String, String>();
//headers.Add("P-Header", "TROPO12171value goes here");
headers.Add("Remote-Party-ID", "\"John Doe\"<sip:jdoe@foo.com>TROPO12171ab;party=calling;id-type=subscriber;privacy=full;screen=yes");
//headers.Add("Remote-Party-ID", "\\yigegang3");

//Answer answer = new Answer();
//answer.Headers = headers;

tropo.Answer(headers);
tropo.Say(say1);
tropo.RenderJSON(Response);
}
}
}

0 comments on commit 1745973

Please sign in to comment.