Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
aa73a879
Commit
aa73a879
authored
May 31, 2018
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
private method name fix + resharper rule + change develtop to master in pull request temple
parent
775c3481
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
57 deletions
+58
-57
PULL_REQUEST_TEMPLATE.md
PULL_REQUEST_TEMPLATE.md
+1
-1
Titanium.Web.Proxy.sln.DotSettings
Titanium.Web.Proxy.sln.DotSettings
+1
-0
Decoder.cs
Titanium.Web.Proxy/Http2/Hpack/Decoder.cs
+6
-6
Encoder.cs
Titanium.Web.Proxy/Http2/Hpack/Encoder.cs
+50
-50
No files found.
PULL_REQUEST_TEMPLATE.md
View file @
aa73a879
Doneness:
-
[
]
Build is okay - I made sure that this change is building successfully.
-
[
]
No Bugs - I made sure that this change is working properly as expected. It doesn't have any bugs that you are aware of.
-
[
]
Branching - If this is not a hotfix, I am making this request against
develop
branch
-
[
]
Branching - If this is not a hotfix, I am making this request against
master
branch
Titanium.Web.Proxy.sln.DotSettings
View file @
aa73a879
...
...
@@ -23,6 +23,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=a4ab2e69_002D4d9c_002D4345_002Dbcd1_002D5541dacf5d38/@EntryIndexedValue"><Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="Method (private)"><ElementKinds><Kind Name="METHOD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy></s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=dda2ffa1_002D435c_002D4111_002D88eb_002D1a7c93c382f0/@EntryIndexedValue"><Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="Property (private)"><ElementKinds><Kind Name="PROPERTY" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy></s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
...
...
Titanium.Web.Proxy/Http2/Hpack/Decoder.cs
View file @
aa73a879
...
...
@@ -173,7 +173,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
break
;
case
State
.
ReadMaxDynamicTableSize
:
int
maxSize
=
D
ecodeULE128
(
input
);
int
maxSize
=
d
ecodeULE128
(
input
);
if
(
maxSize
==
-
1
)
{
return
;
...
...
@@ -190,7 +190,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
break
;
case
State
.
ReadIndexedHeader
:
int
headerIndex
=
D
ecodeULE128
(
input
);
int
headerIndex
=
d
ecodeULE128
(
input
);
if
(
headerIndex
==
-
1
)
{
return
;
...
...
@@ -208,7 +208,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
case
State
.
ReadIndexedHeaderName
:
// Header Name matches an entry in the Header Table
int
nameIndex
=
D
ecodeULE128
(
input
);
int
nameIndex
=
d
ecodeULE128
(
input
);
if
(
nameIndex
==
-
1
)
{
return
;
...
...
@@ -272,7 +272,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
case
State
.
ReadLiteralHeaderNameLength
:
// Header Name is a Literal String
nameLength
=
D
ecodeULE128
(
input
);
nameLength
=
d
ecodeULE128
(
input
);
if
(
nameLength
==
-
1
)
{
return
;
...
...
@@ -388,7 +388,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
case
State
.
ReadLiteralHeaderValueLength
:
// Header Value is a Literal String
valueLength
=
D
ecodeULE128
(
input
);
valueLength
=
d
ecodeULE128
(
input
);
if
(
valueLength
==
-
1
)
{
return
;
...
...
@@ -612,7 +612,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
}
// Unsigned Little Endian Base 128 Variable-Length Integer Encoding
private
static
int
D
ecodeULE128
(
BinaryReader
input
)
private
static
int
d
ecodeULE128
(
BinaryReader
input
)
{
long
markedPosition
=
input
.
BaseStream
.
Position
;
int
result
=
0
;
...
...
Titanium.Web.Proxy/Http2/Hpack/Encoder.cs
View file @
aa73a879
...
...
@@ -66,8 +66,8 @@ namespace Titanium.Web.Proxy.Http2.Hpack
// If the header value is sensitive then it must never be indexed
if
(
sensitive
)
{
int
nameIndex
=
G
etNameIndex
(
name
);
E
ncodeLiteral
(
output
,
name
,
value
,
HpackUtil
.
IndexType
.
Never
,
nameIndex
);
int
nameIndex
=
g
etNameIndex
(
name
);
e
ncodeLiteral
(
output
,
name
,
value
,
HpackUtil
.
IndexType
.
Never
,
nameIndex
);
return
;
}
...
...
@@ -78,11 +78,11 @@ namespace Titanium.Web.Proxy.Http2.Hpack
if
(
staticTableIndex
==
-
1
)
{
int
nameIndex
=
StaticTable
.
GetIndex
(
name
);
E
ncodeLiteral
(
output
,
name
,
value
,
HpackUtil
.
IndexType
.
None
,
nameIndex
);
e
ncodeLiteral
(
output
,
name
,
value
,
HpackUtil
.
IndexType
.
None
,
nameIndex
);
}
else
{
E
ncodeInteger
(
output
,
0x80
,
7
,
staticTableIndex
);
e
ncodeInteger
(
output
,
0x80
,
7
,
staticTableIndex
);
}
return
;
...
...
@@ -93,18 +93,18 @@ namespace Titanium.Web.Proxy.Http2.Hpack
// If the headerSize is greater than the max table size then it must be encoded literally
if
(
headerSize
>
MaxHeaderTableSize
)
{
int
nameIndex
=
G
etNameIndex
(
name
);
E
ncodeLiteral
(
output
,
name
,
value
,
HpackUtil
.
IndexType
.
None
,
nameIndex
);
int
nameIndex
=
g
etNameIndex
(
name
);
e
ncodeLiteral
(
output
,
name
,
value
,
HpackUtil
.
IndexType
.
None
,
nameIndex
);
return
;
}
var
headerField
=
G
etEntry
(
name
,
value
);
var
headerField
=
g
etEntry
(
name
,
value
);
if
(
headerField
!=
null
)
{
int
index
=
G
etIndex
(
headerField
.
Index
)
+
StaticTable
.
Length
;
int
index
=
g
etIndex
(
headerField
.
Index
)
+
StaticTable
.
Length
;
// Section 6.1. Indexed Header Field Representation
E
ncodeInteger
(
output
,
0x80
,
7
,
index
);
e
ncodeInteger
(
output
,
0x80
,
7
,
index
);
}
else
{
...
...
@@ -112,16 +112,16 @@ namespace Titanium.Web.Proxy.Http2.Hpack
if
(
staticTableIndex
!=
-
1
)
{
// Section 6.1. Indexed Header Field Representation
E
ncodeInteger
(
output
,
0x80
,
7
,
staticTableIndex
);
e
ncodeInteger
(
output
,
0x80
,
7
,
staticTableIndex
);
}
else
{
int
nameIndex
=
G
etNameIndex
(
name
);
E
nsureCapacity
(
headerSize
);
int
nameIndex
=
g
etNameIndex
(
name
);
e
nsureCapacity
(
headerSize
);
var
indexType
=
HpackUtil
.
IndexType
.
Incremental
;
E
ncodeLiteral
(
output
,
name
,
value
,
indexType
,
nameIndex
);
A
dd
(
name
,
value
);
e
ncodeLiteral
(
output
,
name
,
value
,
indexType
,
nameIndex
);
a
dd
(
name
,
value
);
}
}
}
...
...
@@ -144,8 +144,8 @@ namespace Titanium.Web.Proxy.Http2.Hpack
}
MaxHeaderTableSize
=
maxHeaderTableSize
;
E
nsureCapacity
(
0
);
E
ncodeInteger
(
output
,
0x20
,
5
,
maxHeaderTableSize
);
e
nsureCapacity
(
0
);
e
ncodeInteger
(
output
,
0x20
,
5
,
maxHeaderTableSize
);
}
/// <summary>
...
...
@@ -155,7 +155,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
/// <param name="mask">Mask.</param>
/// <param name="n">N.</param>
/// <param name="i">The index.</param>
private
static
void
E
ncodeInteger
(
BinaryWriter
output
,
int
mask
,
int
n
,
int
i
)
private
static
void
e
ncodeInteger
(
BinaryWriter
output
,
int
mask
,
int
n
,
int
i
)
{
if
(
n
<
0
||
n
>
8
)
{
...
...
@@ -190,18 +190,18 @@ namespace Titanium.Web.Proxy.Http2.Hpack
/// </summary>
/// <param name="output">Output.</param>
/// <param name="stringLiteral">String literal.</param>
private
void
E
ncodeStringLiteral
(
BinaryWriter
output
,
string
stringLiteral
)
private
void
e
ncodeStringLiteral
(
BinaryWriter
output
,
string
stringLiteral
)
{
var
stringData
=
Encoding
.
UTF8
.
GetBytes
(
stringLiteral
);
int
huffmanLength
=
HuffmanEncoder
.
Instance
.
GetEncodedLength
(
stringData
);
if
(
huffmanLength
<
stringLiteral
.
Length
)
{
E
ncodeInteger
(
output
,
0x80
,
7
,
huffmanLength
);
e
ncodeInteger
(
output
,
0x80
,
7
,
huffmanLength
);
HuffmanEncoder
.
Instance
.
Encode
(
output
,
stringData
);
}
else
{
E
ncodeInteger
(
output
,
0x00
,
7
,
stringData
.
Length
);
e
ncodeInteger
(
output
,
0x00
,
7
,
stringData
.
Length
);
output
.
Write
(
stringData
,
0
,
stringData
.
Length
);
}
}
...
...
@@ -214,7 +214,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
/// <param name="value">Value.</param>
/// <param name="indexType">Index type.</param>
/// <param name="nameIndex">Name index.</param>
private
void
E
ncodeLiteral
(
BinaryWriter
output
,
string
name
,
string
value
,
HpackUtil
.
IndexType
indexType
,
private
void
e
ncodeLiteral
(
BinaryWriter
output
,
string
name
,
string
value
,
HpackUtil
.
IndexType
indexType
,
int
nameIndex
)
{
int
mask
;
...
...
@@ -240,21 +240,21 @@ namespace Titanium.Web.Proxy.Http2.Hpack
throw
new
Exception
(
"should not reach here"
);
}
E
ncodeInteger
(
output
,
mask
,
prefixBits
,
nameIndex
==
-
1
?
0
:
nameIndex
);
e
ncodeInteger
(
output
,
mask
,
prefixBits
,
nameIndex
==
-
1
?
0
:
nameIndex
);
if
(
nameIndex
==
-
1
)
{
E
ncodeStringLiteral
(
output
,
name
);
e
ncodeStringLiteral
(
output
,
name
);
}
E
ncodeStringLiteral
(
output
,
value
);
e
ncodeStringLiteral
(
output
,
value
);
}
private
int
G
etNameIndex
(
string
name
)
private
int
g
etNameIndex
(
string
name
)
{
int
index
=
StaticTable
.
GetIndex
(
name
);
if
(
index
==
-
1
)
{
index
=
G
etIndex
(
name
);
index
=
g
etIndex
(
name
);
if
(
index
>=
0
)
{
index
+=
StaticTable
.
Length
;
...
...
@@ -269,24 +269,24 @@ namespace Titanium.Web.Proxy.Http2.Hpack
/// Removes the oldest entry from the dynamic table until sufficient space is available.
/// </summary>
/// <param name="headerSize">Header size.</param>
private
void
E
nsureCapacity
(
int
headerSize
)
private
void
e
nsureCapacity
(
int
headerSize
)
{
while
(
size
+
headerSize
>
MaxHeaderTableSize
)
{
int
index
=
L
ength
();
int
index
=
l
ength
();
if
(
index
==
0
)
{
break
;
}
R
emove
();
r
emove
();
}
}
/// <summary>
/// Return the number of header fields in the dynamic table.
/// </summary>
private
int
L
ength
()
private
int
l
ength
()
{
return
size
==
0
?
0
:
head
.
After
.
Index
-
head
.
Before
.
Index
+
1
;
}
...
...
@@ -298,15 +298,15 @@ namespace Titanium.Web.Proxy.Http2.Hpack
/// <returns>The entry.</returns>
/// <param name="name">Name.</param>
/// <param name="value">Value.</param>
private
HeaderEntry
G
etEntry
(
string
name
,
string
value
)
private
HeaderEntry
g
etEntry
(
string
name
,
string
value
)
{
if
(
L
ength
()
==
0
||
name
==
null
||
value
==
null
)
if
(
l
ength
()
==
0
||
name
==
null
||
value
==
null
)
{
return
null
;
}
int
h
=
H
ash
(
name
);
int
i
=
I
ndex
(
h
);
int
h
=
h
ash
(
name
);
int
i
=
i
ndex
(
h
);
for
(
var
e
=
headerFields
[
i
];
e
!=
null
;
e
=
e
.
Next
)
{
if
(
e
.
Hash
==
h
&&
Equals
(
name
,
e
.
Name
)
&&
Equals
(
value
,
e
.
Value
))
...
...
@@ -324,15 +324,15 @@ namespace Titanium.Web.Proxy.Http2.Hpack
/// </summary>
/// <returns>The index.</returns>
/// <param name="name">Name.</param>
private
int
G
etIndex
(
string
name
)
private
int
g
etIndex
(
string
name
)
{
if
(
L
ength
()
==
0
||
name
==
null
)
if
(
l
ength
()
==
0
||
name
==
null
)
{
return
-
1
;
}
int
h
=
H
ash
(
name
);
int
i
=
I
ndex
(
h
);
int
h
=
h
ash
(
name
);
int
i
=
Encoder
.
i
ndex
(
h
);
int
index
=
-
1
;
for
(
var
e
=
headerFields
[
i
];
e
!=
null
;
e
=
e
.
Next
)
{
...
...
@@ -343,7 +343,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
}
}
return
G
etIndex
(
index
);
return
g
etIndex
(
index
);
}
/// <summary>
...
...
@@ -351,7 +351,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
/// </summary>
/// <returns>The index.</returns>
/// <param name="index">Index.</param>
private
int
G
etIndex
(
int
index
)
private
int
g
etIndex
(
int
index
)
{
if
(
index
==
-
1
)
{
...
...
@@ -370,25 +370,25 @@ namespace Titanium.Web.Proxy.Http2.Hpack
/// </summary>
/// <param name="name">Name.</param>
/// <param name="value">Value.</param>
private
void
A
dd
(
string
name
,
string
value
)
private
void
a
dd
(
string
name
,
string
value
)
{
int
headerSize
=
HttpHeader
.
SizeOf
(
name
,
value
);
// Clear the table if the header field size is larger than the capacity.
if
(
headerSize
>
MaxHeaderTableSize
)
{
C
lear
();
c
lear
();
return
;
}
// Evict oldest entries until we have enough capacity.
while
(
size
+
headerSize
>
MaxHeaderTableSize
)
{
R
emove
();
r
emove
();
}
int
h
=
H
ash
(
name
);
int
i
=
I
ndex
(
h
);
int
h
=
h
ash
(
name
);
int
i
=
i
ndex
(
h
);
var
old
=
headerFields
[
i
];
var
e
=
new
HeaderEntry
(
h
,
name
,
value
,
head
.
Before
.
Index
-
1
,
old
);
headerFields
[
i
]
=
e
;
...
...
@@ -399,7 +399,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
/// <summary>
/// Remove and return the oldest header field from the dynamic table.
/// </summary>
private
HttpHeader
R
emove
()
private
HttpHeader
r
emove
()
{
if
(
size
==
0
)
{
...
...
@@ -408,7 +408,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
var
eldest
=
head
.
After
;
int
h
=
eldest
.
Hash
;
int
i
=
I
ndex
(
h
);
int
i
=
i
ndex
(
h
);
var
prev
=
headerFields
[
i
];
var
e
=
prev
;
while
(
e
!=
null
)
...
...
@@ -440,7 +440,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
/// <summary>
/// Remove all entries from the dynamic table.
/// </summary>
private
void
C
lear
()
private
void
c
lear
()
{
for
(
int
i
=
0
;
i
<
headerFields
.
Length
;
i
++)
{
...
...
@@ -456,7 +456,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
/// </summary>
/// <returns><c>true</c> if hash name; otherwise, <c>false</c>.</returns>
/// <param name="name">Name.</param>
private
static
int
H
ash
(
string
name
)
private
static
int
h
ash
(
string
name
)
{
int
h
=
0
;
for
(
int
i
=
0
;
i
<
name
.
Length
;
i
++)
...
...
@@ -481,7 +481,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
/// Returns the index into the hash table for the hash code h.
/// </summary>
/// <param name="h">The height.</param>
private
static
int
I
ndex
(
int
h
)
private
static
int
i
ndex
(
int
h
)
{
return
h
%
bucketSize
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment