Permalink
Browse files

Ignoring BOM in HttpEntityManager.

  • Loading branch information...
1 parent 3216532 commit 2dc1b63240b7916fda888d1a1e0edcd2813d2ce0 @anakryiko anakryiko committed Nov 14, 2012
Showing with 411 additions and 421 deletions.
  1. +10 −14 src/EventStore/EventStore.Core.Tests/Services/Transport/Http/auto_convertion.cs
  2. +1 −0 src/EventStore/EventStore.Core.Tests/Services/Transport/Http/ping_controller_should.cs
  3. +7 −1 src/EventStore/EventStore.Core/EventStore.Core.csproj
  4. +7 −11 src/EventStore/EventStore.Core/Services/Transport/Http/AutoEventConverter.cs
  5. +0 −378 src/EventStore/EventStore.Core/Services/Transport/Http/Codecs.cs
  6. +49 −0 src/EventStore/EventStore.Core/Services/Transport/Http/Codecs/Codec.cs
  7. +54 −0 src/EventStore/EventStore.Core/Services/Transport/Http/Codecs/CustomCodec.cs
  8. +72 −0 src/EventStore/EventStore.Core/Services/Transport/Http/Codecs/JsonCodec.cs
  9. +30 −0 src/EventStore/EventStore.Core/Services/Transport/Http/Codecs/ManualEncoding.cs
  10. +30 −0 src/EventStore/EventStore.Core/Services/Transport/Http/Codecs/NoCodec.cs
  11. +33 −0 src/EventStore/EventStore.Core/Services/Transport/Http/Codecs/TextCodec.cs
  12. +83 −0 src/EventStore/EventStore.Core/Services/Transport/Http/Codecs/XmlCodec.cs
  13. +1 −0 src/EventStore/EventStore.Core/Services/Transport/Http/Controllers/AdminController.cs
  14. +2 −2 src/EventStore/EventStore.Core/Services/Transport/Http/Controllers/AtomControllerDefinitions.cs
  15. +1 −0 src/EventStore/EventStore.Core/Services/Transport/Http/Controllers/PingController.cs
  16. +1 −0 src/EventStore/EventStore.Core/Services/Transport/Http/Controllers/ReadEventDataController.cs
  17. +1 −0 src/EventStore/EventStore.Core/Services/Transport/Http/Controllers/StatController.cs
  18. +1 −0 src/EventStore/EventStore.Core/Services/Transport/Http/Controllers/WebSiteController.cs
  19. +1 −0 src/EventStore/EventStore.Core/Services/Transport/Http/HttpService.cs
  20. +1 −0 src/EventStore/EventStore.Core/Util/MiniWeb.cs
  21. +1 −0 src/EventStore/EventStore.Projections.Core/Services/Http/ProjectionsController.cs
  22. +1 −0 src/EventStore/EventStore.TestClient/Commands/DvuBasic/BankAccountBasicProducer.cs
  23. +1 −0 src/EventStore/EventStore.TestClient/Commands/RunTestScenarios/BankAccountEvent.cs
  24. +1 −0 src/EventStore/EventStore.TestClient/Commands/RunTestScenarios/ProjectionsKillScenario.cs
  25. +1 −0 src/EventStore/EventStore.TestClient/Commands/WriteFloodHttpProcessor.cs
  26. +1 −0 src/EventStore/EventStore.TestClient/Commands/WriteFloodWaitingHttpProcessor.cs
  27. +1 −0 src/EventStore/EventStore.TestClient/Commands/WriteHttpProcessor.cs
  28. +1 −0 src/EventStore/EventStore.TestClient/Commands/WriteLongTermHttpProcessor.cs
  29. +1 −1 src/EventStore/EventStore.Transport.Http/EntityManagement/HttpEntity.cs
  30. +17 −14 src/EventStore/EventStore.Transport.Http/EntityManagement/HttpEntityManager.cs
@@ -5,6 +5,7 @@
using EventStore.Core.Messages;
using EventStore.Core.Services.Storage.ReaderIndex;
using EventStore.Core.Services.Transport.Http;
+using EventStore.Core.Services.Transport.Http.Codecs;
using EventStore.Core.TransactionLog.LogRecords;
using NUnit.Framework;
using System.Linq;
@@ -52,14 +53,14 @@ private static string XmlReadFormat
}
}
- public static byte[] GetJsonWrite(string data, string metadata)
+ public static string GetJsonWrite(string data, string metadata)
{
- return Encoding.UTF8.GetBytes(string.Format(JsonWriteFormat,
- "-1",
- String.Format("\"{0}\"", Guid.NewGuid()),
- "\"type\"",
- data,
- metadata));
+ return string.Format(JsonWriteFormat,
+ "-1",
+ String.Format("\"{0}\"", Guid.NewGuid()),
+ "\"type\"",
+ data,
+ metadata);
}
public static string GetJsonReadResult(ClientMessage.ReadEventCompleted completed, bool dataJson = true, bool metadataJson = true)
@@ -72,14 +73,9 @@ public static string GetJsonReadResult(ClientMessage.ReadEventCompleted complete
metadataJson ? JsonMetadata : WrapIntoQuotes(AsString(completed.Record.Metadata)));
}
- public static byte[] GetXmlWrite(string data, string metadata, bool withBom = true)
+ public static string GetXmlWrite(string data, string metadata)
{
- IEnumerable<byte> result = Enumerable.Empty<byte>();
- if (withBom)
- result = result.Concat(Encoding.UTF8.GetPreamble());
- result = result.Concat(Encoding.UTF8.GetBytes(
- string.Format(XmlWriteFormat, "-1", Guid.NewGuid(), "type", data, metadata)));
- return result.ToArray();
+ return string.Format(XmlWriteFormat, "-1", Guid.NewGuid(), "type", data, metadata);
}
public static string GetXmlReadResult(ClientMessage.ReadEventCompleted completed, bool dataJson = true, bool metadataJson = true)
@@ -31,6 +31,7 @@
using EventStore.Common.Utils;
using EventStore.Core.Messages;
using EventStore.Core.Services.Transport.Http;
+using EventStore.Core.Services.Transport.Http.Codecs;
using EventStore.Transport.Http;
using NUnit.Framework;
@@ -144,6 +144,12 @@
<Compile Include="Services\Storage\StorageScavenger.cs" />
<Compile Include="Services\SystemNames.cs" />
<Compile Include="Services\RequestManager\Managers\TransactionCommitTwoPhaseRequestManager.cs" />
+ <Compile Include="Services\Transport\Http\Codecs\CustomCodec.cs" />
+ <Compile Include="Services\Transport\Http\Codecs\JsonCodec.cs" />
+ <Compile Include="Services\Transport\Http\Codecs\ManualEncoding.cs" />
+ <Compile Include="Services\Transport\Http\Codecs\NoCodec.cs" />
+ <Compile Include="Services\Transport\Http\Codecs\TextCodec.cs" />
+ <Compile Include="Services\Transport\Http\Codecs\XmlCodec.cs" />
<Compile Include="Services\Transport\Http\Controllers\WebSiteController.cs" />
<Compile Include="Services\RequestManager\Managers\TwoPhaseRequestManagerBase.cs" />
<Compile Include="Services\RequestManager\Managers\WriteStreamTwoPhaseRequestManager.cs" />
@@ -209,7 +215,7 @@
<Compile Include="Services\Storage\ReaderIndex\ReadIndexStats.cs" />
<Compile Include="Services\Storage\StorageChaser.cs" />
<Compile Include="Services\Storage\StorageReader.cs" />
- <Compile Include="Services\Transport\Http\Codecs.cs" />
+ <Compile Include="Services\Transport\Http\Codecs\Codec.cs" />
<Compile Include="Services\Transport\Http\ControllerAction.cs" />
<Compile Include="Services\Transport\Http\Controllers\AdminController.cs" />
<Compile Include="Services\Transport\Http\Controllers\CommunicationController.cs" />
@@ -34,6 +34,7 @@
using EventStore.Common.Log;
using EventStore.Core.Data;
using EventStore.Core.Messages;
+using EventStore.Core.Services.Transport.Http.Codecs;
using EventStore.Core.TransactionLog.LogRecords;
using EventStore.Transport.Http;
using Newtonsoft.Json;
@@ -77,7 +78,7 @@ public static string SmartFormat(ClientMessage.ReadEventCompleted completed, ICo
}
}
- public static Tuple<int, Event[]> SmartParse(byte[] request, ICodec sourceCodec)
+ public static Tuple<int, Event[]> SmartParse(string request, ICodec sourceCodec)
{
var write = Load(request, sourceCodec);
if (write == null || write.Events == null || write.Events.Length == 0)
@@ -87,7 +88,7 @@ public static string SmartFormat(ClientMessage.ReadEventCompleted completed, ICo
return new Tuple<int, Event[]>(write.ExpectedVersion, events);
}
- private static HttpClientMessageDto.WriteEventsDynamic Load(byte[] data, ICodec sourceCodec)
+ private static HttpClientMessageDto.WriteEventsDynamic Load(string data, ICodec sourceCodec)
{
switch(sourceCodec.ContentType)
{
@@ -105,21 +106,16 @@ private static HttpClientMessageDto.WriteEventsDynamic Load(byte[] data, ICodec
}
}
- private static HttpClientMessageDto.WriteEventsDynamic LoadFromJson(byte[] json)
+ private static HttpClientMessageDto.WriteEventsDynamic LoadFromJson(string json)
{
- return Codec.Json.From<HttpClientMessageDto.WriteEventsDynamic>(Encoding.UTF8.GetString(json));
+ return Codec.Json.From<HttpClientMessageDto.WriteEventsDynamic>(json);
}
- private static HttpClientMessageDto.WriteEventsDynamic LoadFromXml(byte[] xml)
+ private static HttpClientMessageDto.WriteEventsDynamic LoadFromXml(string xml)
{
try
{
- XDocument doc;
- using (var memStream = new MemoryStream(xml))
- using (var xmlTextReader = new XmlTextReader(memStream))
- {
- doc = XDocument.Load(xmlTextReader);
- }
+ XDocument doc = XDocument.Parse(xml);
XNamespace jsonNsValue = "http://james.newtonking.com/projects/json";
XName jsonNsName = XNamespace.Xmlns + "json";
Oops, something went wrong.

0 comments on commit 2dc1b63

Please sign in to comment.