THRIFT-5384 Improved error message for HTTP transports
Client: Delphi
Patch: Jens Geyer
diff --git a/lib/delphi/src/Thrift.Utils.pas b/lib/delphi/src/Thrift.Utils.pas
index bfd020e..4a75af8 100644
--- a/lib/delphi/src/Thrift.Utils.pas
+++ b/lib/delphi/src/Thrift.Utils.pas
@@ -80,6 +80,8 @@
public
class function IsHighSurrogate( const c : Char) : Boolean; static; inline;
class function IsLowSurrogate( const c : Char) : Boolean; static; inline;
+
+ class function IsHtmlDoctype( const fourBytes : Integer) : Boolean; static;
end;
EnumUtils<T> = class sealed
@@ -259,6 +261,30 @@
end;
+class function CharUtils.IsHtmlDoctype( const fourBytes : Integer) : Boolean;
+var pc : PAnsiChar;
+const HTML_BEGIN : PAnsiChar = 'OD!<'; // first 4 bytes of '<!DOCTYPE ' in LE byte order
+begin
+ pc := @fourBytes;
+
+ if UpCase(pc^) <> HTML_BEGIN[0]
+ then Exit(FALSE);
+
+ Inc( pc);
+ if UpCase(pc^) <> HTML_BEGIN[1]
+ then Exit(FALSE);
+
+
+ Inc( pc);
+ if UpCase(pc^) <> HTML_BEGIN[2]
+ then Exit(FALSE);
+
+ Inc( pc);
+ result := (UpCase(pc^) = HTML_BEGIN[3]);
+end;
+
+
+
{$IFDEF Win64}
function InterlockedCompareExchange64( var Target : Int64; Exchange, Comparand : Int64) : Int64; inline;