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
13bd6bc0
Commit
13bd6bc0
authored
Oct 28, 2016
by
Jehonathan
Committed by
GitHub
Oct 28, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #140 from nordinrahman/proxyException
Proxy exception
parents
89edd211
cb37a12d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
104 additions
and
8 deletions
+104
-8
BodyNotFoundException.cs
Titanium.Web.Proxy/Exceptions/BodyNotFoundException.cs
+1
-1
ProxyAuthorizationException.cs
Titanium.Web.Proxy/Exceptions/ProxyAuthorizationException.cs
+28
-0
ProxyException.cs
Titanium.Web.Proxy/Exceptions/ProxyException.cs
+27
-0
ProxyHttpException.cs
Titanium.Web.Proxy/Exceptions/ProxyHttpException.cs
+30
-0
ProxyAuthorizationHandler.cs
Titanium.Web.Proxy/ProxyAuthorizationHandler.cs
+8
-4
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+3
-2
ResponseHandler.cs
Titanium.Web.Proxy/ResponseHandler.cs
+2
-1
Titanium.Web.Proxy.csproj
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+5
-0
No files found.
Titanium.Web.Proxy/Exceptions/BodyNotFoundException.cs
View file @
13bd6bc0
...
...
@@ -5,7 +5,7 @@ namespace Titanium.Web.Proxy.Exceptions
/// <summary>
/// An expception thrown when body is unexpectedly empty
/// </summary>
public
class
BodyNotFoundException
:
Exception
public
class
BodyNotFoundException
:
Proxy
Exception
{
public
BodyNotFoundException
(
string
message
)
:
base
(
message
)
...
...
Titanium.Web.Proxy/Exceptions/ProxyAuthorizationException.cs
0 → 100644
View file @
13bd6bc0
using
System
;
using
System.Collections.Generic
;
using
Titanium.Web.Proxy.Models
;
namespace
Titanium.Web.Proxy.Exceptions
{
/// <summary>
/// Proxy authorization exception
/// </summary>
public
class
ProxyAuthorizationException
:
ProxyException
{
/// <summary>
/// Instantiate new instance
/// </summary>
/// <param name="message">Exception message</param>
/// <param name="innerException">Inner exception associated to upstream proxy authorization</param>
/// <param name="headers">Http's headers associated</param>
public
ProxyAuthorizationException
(
string
message
,
Exception
innerException
,
IEnumerable
<
HttpHeader
>
headers
)
:
base
(
message
,
innerException
)
{
Headers
=
headers
;
}
/// <summary>
/// Headers associated with the authorization exception
/// </summary>
public
IEnumerable
<
HttpHeader
>
Headers
{
get
;
}
}
}
\ No newline at end of file
Titanium.Web.Proxy/Exceptions/ProxyException.cs
0 → 100644
View file @
13bd6bc0
using
System
;
namespace
Titanium.Web.Proxy.Exceptions
{
/// <summary>
/// Base class exception associated with this proxy implementation
/// </summary>
public
abstract
class
ProxyException
:
Exception
{
/// <summary>
/// Instantiate a new instance of this exception - must be invoked by derived classes' constructors
/// </summary>
/// <param name="message">Exception message</param>
protected
ProxyException
(
string
message
)
:
base
(
message
)
{
}
/// <summary>
/// Instantiate this exception - must be invoked by derived classes' constructors
/// </summary>
/// <param name="message">Excception message</param>
/// <param name="innerException">Inner exception associated</param>
protected
ProxyException
(
string
message
,
Exception
innerException
)
:
base
(
message
,
innerException
)
{
}
}
}
\ No newline at end of file
Titanium.Web.Proxy/Exceptions/ProxyHttpException.cs
0 → 100644
View file @
13bd6bc0
using
System
;
using
Titanium.Web.Proxy.EventArguments
;
namespace
Titanium.Web.Proxy.Exceptions
{
/// <summary>
/// Proxy HTTP exception
/// </summary>
public
class
ProxyHttpException
:
ProxyException
{
/// <summary>
/// Instantiate new instance
/// </summary>
/// <param name="message">Message for this exception</param>
/// <param name="innerException">Associated inner exception</param>
/// <param name="sessionEventArgs">Instance of <see cref="EventArguments.SessionEventArgs"/> associated to the exception</param>
public
ProxyHttpException
(
string
message
,
Exception
innerException
,
SessionEventArgs
sessionEventArgs
)
:
base
(
message
,
innerException
)
{
SessionEventArgs
=
sessionEventArgs
;
}
/// <summary>
/// Gets session info associated to the exception
/// </summary>
/// <remarks>
/// This object should not be edited
/// </remarks>
public
SessionEventArgs
SessionEventArgs
{
get
;
}
}
}
\ No newline at end of file
Titanium.Web.Proxy/ProxyAuthorizationHandler.cs
View file @
13bd6bc0
...
...
@@ -4,6 +4,7 @@ using System.IO;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.Exceptions
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Models
;
...
...
@@ -17,10 +18,13 @@ namespace Titanium.Web.Proxy
if
(
AuthenticateUserFunc
==
null
)
{
return
true
;
}
}
var
httpHeaders
=
Headers
as
HttpHeader
[]
??
Headers
.
ToArray
();
try
{
if
(!
Headers
.
Where
(
t
=>
t
.
Name
==
"Proxy-Authorization"
).
Any
())
if
(!
http
Headers
.
Where
(
t
=>
t
.
Name
==
"Proxy-Authorization"
).
Any
())
{
await
WriteResponseStatus
(
new
Version
(
1
,
1
),
"407"
,
...
...
@@ -36,7 +40,7 @@ namespace Titanium.Web.Proxy
}
else
{
var
headerValue
=
Headers
.
Where
(
t
=>
t
.
Name
==
"Proxy-Authorization"
).
FirstOrDefault
().
Value
.
Trim
();
var
headerValue
=
http
Headers
.
Where
(
t
=>
t
.
Name
==
"Proxy-Authorization"
).
FirstOrDefault
().
Value
.
Trim
();
if
(!
headerValue
.
ToLower
().
StartsWith
(
"basic"
))
{
//Return not authorized
...
...
@@ -75,7 +79,7 @@ namespace Titanium.Web.Proxy
}
catch
(
Exception
e
)
{
ExceptionFunc
(
e
);
ExceptionFunc
(
new
ProxyAuthorizationException
(
"Error whilst authorizing request"
,
e
,
httpHeaders
)
);
//Return not authorized
await
WriteResponseStatus
(
new
Version
(
1
,
1
),
"407"
,
"Proxy Authentication Invalid"
,
clientStreamWriter
);
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
13bd6bc0
...
...
@@ -6,6 +6,7 @@ using System.Net.Security;
using
System.Net.Sockets
;
using
System.Security.Authentication
;
using
System.Text.RegularExpressions
;
using
Titanium.Web.Proxy.Exceptions
;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Network
;
...
...
@@ -338,7 +339,7 @@ namespace Titanium.Web.Proxy
}
catch
(
Exception
e
)
{
ExceptionFunc
(
e
);
ExceptionFunc
(
new
ProxyHttpException
(
"Error occured whilst handling session request (internal)"
,
e
,
args
)
);
Dispose
(
args
.
ProxyClient
.
ClientStream
,
args
.
ProxyClient
.
ClientStreamReader
,
args
.
ProxyClient
.
ClientStreamWriter
,
args
);
return
;
}
...
...
@@ -501,7 +502,7 @@ namespace Titanium.Web.Proxy
}
catch
(
Exception
e
)
{
ExceptionFunc
(
e
);
ExceptionFunc
(
new
ProxyHttpException
(
"Error occured whilst handling session request"
,
e
,
args
)
);
Dispose
(
clientStream
,
clientStreamReader
,
clientStreamWriter
,
args
);
break
;
}
...
...
Titanium.Web.Proxy/ResponseHandler.cs
View file @
13bd6bc0
...
...
@@ -5,6 +5,7 @@ using Titanium.Web.Proxy.EventArguments;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Compression
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.Exceptions
;
using
Titanium.Web.Proxy.Extensions
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Helpers
;
...
...
@@ -121,7 +122,7 @@ namespace Titanium.Web.Proxy
}
catch
(
Exception
e
)
{
ExceptionFunc
(
e
);
ExceptionFunc
(
new
ProxyHttpException
(
"Error occured wilst handling session response"
,
e
,
args
));
Dispose
(
args
.
ProxyClient
.
ClientStream
,
args
.
ProxyClient
.
ClientStreamReader
,
args
.
ProxyClient
.
ClientStreamWriter
,
args
);
}
...
...
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
13bd6bc0
...
...
@@ -25,6 +25,7 @@
<AllowUnsafeBlocks>
true
</AllowUnsafeBlocks>
<TargetFrameworkVersion>
v4.5
</TargetFrameworkVersion>
<Prefer32Bit>
false
</Prefer32Bit>
<DocumentationFile>
bin\Debug\Titanium.Web.Proxy.XML
</DocumentationFile>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"
>
<PlatformTarget>
AnyCPU
</PlatformTarget>
...
...
@@ -32,6 +33,7 @@
<TargetFrameworkVersion>
v4.5
</TargetFrameworkVersion>
<DefineConstants>
NET45
</DefineConstants>
<Prefer32Bit>
false
</Prefer32Bit>
<DocumentationFile>
bin\Release\Titanium.Web.Proxy.XML
</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"Ionic.Zip, Version=1.9.8.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL"
>
...
...
@@ -68,6 +70,9 @@
<Compile
Include=
"Network\CertificateMaker.cs"
/>
<Compile
Include=
"Network\ProxyClient.cs"
/>
<Compile
Include=
"Exceptions\BodyNotFoundException.cs"
/>
<Compile
Include=
"Exceptions\ProxyAuthorizationException.cs"
/>
<Compile
Include=
"Exceptions\ProxyException.cs"
/>
<Compile
Include=
"Exceptions\ProxyHttpException.cs"
/>
<Compile
Include=
"Extensions\HttpWebResponseExtensions.cs"
/>
<Compile
Include=
"Extensions\HttpWebRequestExtensions.cs"
/>
<Compile
Include=
"Network\CertificateManager.cs"
/>
...
...
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