Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uHttpSharp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Scott Duncan
uHttpSharp
Commits
af33f529
Commit
af33f529
authored
Feb 07, 2014
by
Shani Elharrar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added IHttpPost (With Raw and Parsed data).
parent
4b12be58
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
32 deletions
+121
-32
uhttpsharp.sln
uhttpsharp.sln
+17
-13
uhttpsharp/Headers/HttpHeaders.cs
uhttpsharp/Headers/HttpHeaders.cs
+87
-10
uhttpsharp/HttpRequest.cs
uhttpsharp/HttpRequest.cs
+12
-4
uhttpsharp/RequestProviders/HttpRequestProvider.cs
uhttpsharp/RequestProviders/HttpRequestProvider.cs
+5
-5
No files found.
uhttpsharp.sln
View file @
af33f529
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uhttpsharp.Demo", "uhttpsharp-demo\uhttpsharp.Demo.csproj", "{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uhttpsharp", "uhttpsharp\uhttpsharp.csproj", "{3D681959-4DA3-4A71-A68B-704D6411D5EA}"
...
...
@@ -32,16 +30,6 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Debug|Any CPU.ActiveCfg = Debug|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Debug|Mixed Platforms.Build.0 = Debug|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Debug|x86.ActiveCfg = Debug|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Debug|x86.Build.0 = Debug|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Release|Any CPU.ActiveCfg = Release|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Release|Mixed Platforms.ActiveCfg = Release|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Release|Mixed Platforms.Build.0 = Release|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Release|x86.ActiveCfg = Release|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Release|x86.Build.0 = Release|x86
{3D681959-4DA3-4A71-A68B-704D6411D5EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D681959-4DA3-4A71-A68B-704D6411D5EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D681959-4DA3-4A71-A68B-704D6411D5EA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
...
...
@@ -62,6 +50,22 @@ Global
{41C9BDAC-21BE-4C50-933D-9E047F767E63}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{41C9BDAC-21BE-4C50-933D-9E047F767E63}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{41C9BDAC-21BE-4C50-933D-9E047F767E63}.Release|x86.ActiveCfg = Release|Any CPU
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Debug|Any CPU.ActiveCfg = Debug|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Debug|Any CPU.Build.0 = Debug|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Debug|Mixed Platforms.Build.0 = Debug|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Debug|x86.ActiveCfg = Debug|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Debug|x86.Build.0 = Debug|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Release|Any CPU.ActiveCfg = Release|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Release|Mixed Platforms.ActiveCfg = Release|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Release|Mixed Platforms.Build.0 = Release|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Release|x86.ActiveCfg = Release|x86
{55C5E8D2-F55E-4B9F-B96F-FCE201739D07}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = uhttpsharp-demo\uhttpsharp.Demo.csproj
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
uhttpsharp/Headers/HttpHeaders.cs
View file @
af33f529
...
...
@@ -5,9 +5,96 @@ using System.Diagnostics;
using
System.IO
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Security.AccessControl
;
namespace
uhttpsharp.Headers
{
internal
class
EmptyHttpPost
:
IHttpPost
{
private
static
readonly
byte
[]
_emptyBytes
=
new
byte
[
0
];
public
static
readonly
IHttpPost
Empty
=
new
EmptyHttpPost
();
private
EmptyHttpPost
()
{
}
#
region
IHttpPost
implementation
public
byte
[]
Raw
{
get
{
return
_emptyBytes
;
}
}
public
IHttpHeaders
Parsed
{
get
{
return
EmptyHttpHeaders
.
Empty
;
}
}
#
endregion
}
internal
class
HttpPost
:
IHttpPost
{
public
static
async
Task
<
IHttpPost
>
Create
(
StreamReader
reader
,
int
postContentLength
)
{
byte
[]
raw
=
new
byte
[
postContentLength
];
int
readBytes
=
await
reader
.
BaseStream
.
ReadAsync
(
raw
,
0
,
postContentLength
);
return
new
HttpPost
(
raw
,
readBytes
);
}
private
readonly
int
_readBytes
;
private
readonly
byte
[]
_raw
;
private
readonly
Lazy
<
IHttpHeaders
>
_parsed
;
public
HttpPost
(
byte
[]
raw
,
int
readBytes
)
{
_raw
=
raw
;
_readBytes
=
readBytes
;
_parsed
=
new
Lazy
<
IHttpHeaders
>(
Parse
);
}
private
IHttpHeaders
Parse
()
{
string
body
=
Encoding
.
UTF8
.
GetString
(
_raw
,
0
,
_readBytes
);
var
parsed
=
new
QueryStringHttpHeaders
(
body
);
return
parsed
;
}
#
region
IHttpPost
implementation
public
byte
[]
Raw
{
get
{
return
_raw
;
}
}
public
IHttpHeaders
Parsed
{
get
{
return
_parsed
.
Value
;
}
}
#
endregion
}
[
DebuggerDisplay
(
"{Count} Headers"
)]
[
DebuggerTypeProxy
(
typeof
(
HttpHeadersDebuggerProxy
))]
internal
class
HttpHeaders
:
IHttpHeaders
...
...
@@ -38,16 +125,6 @@ namespace uhttpsharp.Headers
return
GetEnumerator
();
}
public
static
async
Task
<
IHttpHeaders
>
FromPost
(
StreamReader
reader
,
int
postContentLength
)
{
byte
[]
buffer
=
new
byte
[
postContentLength
];
var
readBytes
=
await
reader
.
BaseStream
.
ReadAsync
(
buffer
,
0
,
postContentLength
);
string
body
=
Encoding
.
UTF8
.
GetString
(
buffer
,
0
,
readBytes
);
return
new
QueryStringHttpHeaders
(
body
);
}
internal
int
Count
{
...
...
uhttpsharp/HttpRequest.cs
View file @
af33f529
...
...
@@ -33,9 +33,9 @@ namespace uhttpsharp
private
readonly
Uri
_uri
;
private
readonly
string
[]
_requestParameters
;
private
readonly
IHttpHeaders
_queryString
;
private
readonly
IHttp
Headers
_post
;
private
readonly
IHttp
Post
_post
;
public
HttpRequest
(
IHttpHeaders
headers
,
HttpMethods
method
,
string
protocol
,
Uri
uri
,
string
[]
requestParameters
,
IHttpHeaders
queryString
,
IHttp
Headers
post
)
public
HttpRequest
(
IHttpHeaders
headers
,
HttpMethods
method
,
string
protocol
,
Uri
uri
,
string
[]
requestParameters
,
IHttpHeaders
queryString
,
IHttp
Post
post
)
{
_headers
=
headers
;
_method
=
method
;
...
...
@@ -71,7 +71,7 @@ namespace uhttpsharp
get
{
return
_requestParameters
;
}
}
public
IHttp
Headers
Post
public
IHttp
Post
Post
{
get
{
return
_post
;
}
}
...
...
@@ -108,10 +108,18 @@ namespace uhttpsharp
string
[]
RequestParameters
{
get
;
}
IHttp
Headers
Post
{
get
;
}
IHttp
Post
Post
{
get
;
}
IHttpHeaders
QueryString
{
get
;
}
}
public
interface
IHttpPost
{
byte
[]
Raw
{
get
;}
IHttpHeaders
Parsed
{
get
;}
}
...
...
uhttpsharp/RequestProviders/HttpRequestProvider.cs
View file @
af33f529
...
...
@@ -43,7 +43,7 @@ namespace uhttpsharp.RequestProviders
}
IHttpHeaders
headers
=
new
HttpHeaders
(
headersRaw
);
IHttp
Headers
post
=
await
GetPostData
(
streamReader
,
headers
);
IHttp
Post
post
=
await
GetPostData
(
streamReader
,
headers
);
return
new
HttpRequest
(
headers
,
httpMethod
,
httpProtocol
,
uri
,
uri
.
OriginalString
.
Split
(
Separators
,
StringSplitOptions
.
RemoveEmptyEntries
),
queryString
,
post
);
...
...
@@ -64,17 +64,17 @@ namespace uhttpsharp.RequestProviders
return
queryString
;
}
private
static
async
Task
<
IHttp
Headers
>
GetPostData
(
StreamReader
streamReader
,
IHttpHeaders
headers
)
private
static
async
Task
<
IHttp
Post
>
GetPostData
(
StreamReader
streamReader
,
IHttpHeaders
headers
)
{
int
postContentLength
;
IHttp
Headers
post
;
IHttp
Post
post
;
if
(
headers
.
TryGetByName
(
"content-length"
,
out
postContentLength
))
{
post
=
await
Http
Headers
.
FromPost
(
streamReader
,
postContentLength
);
post
=
await
Http
Post
.
Create
(
streamReader
,
postContentLength
);
}
else
{
post
=
EmptyHttp
Headers
.
Empty
;
post
=
EmptyHttp
Post
.
Empty
;
}
return
post
;
}
...
...
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