Commit 16add7ec authored by Shani Elharrar's avatar Shani Elharrar

Modified stuff to internal. Renamed HttpRequestV2 to HttpRequest.

parent 3886e645
......@@ -17,10 +17,8 @@
*/
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography.X509Certificates;
using uhttpsharp;
using uhttpsharp.Handlers;
using uhttpsharp.Listeners;
......@@ -43,7 +41,7 @@ namespace uhttpsharpdemo
httpServer.Use(new ExceptionHandler());
httpServer.Use(new TimingHandler());
httpServer.Use(new HttpRouter().With(string.Empty, new IndexHandler())
.With("about", new AboutHandler())
.With("strings", new RestHandler<string>(new StringsRestController(), new JsonResponseProvider())));
......@@ -59,7 +57,7 @@ namespace uhttpsharpdemo
httpServer.Start();
Console.ReadLine();
}
}
}
}
\ No newline at end of file
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
namespace uhttpsharp.Headers
{
public class EmptyHttpHeaders : IHttpHeaders
[DebuggerDisplay("Empty Headers")]
internal class EmptyHttpHeaders : IHttpHeaders
{
public static readonly IHttpHeaders Empty = new EmptyHttpHeaders();
......@@ -32,5 +34,6 @@ namespace uhttpsharp.Headers
value = null;
return false;
}
}
}
\ No newline at end of file
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace uhttpsharp.Headers
{
public class HttpHeaders : IHttpHeaders
[DebuggerDisplay("{Count} Headers")]
[DebuggerTypeProxy(typeof(HttpHeadersDebuggerProxy))]
internal class HttpHeaders : IHttpHeaders
{
private readonly IDictionary<string, string> _values;
......@@ -43,5 +47,59 @@ namespace uhttpsharp.Headers
return new QueryStringHttpHeaders(body);
}
internal int Count
{
get
{
return _values.Count;
}
}
}
internal class HttpHeadersDebuggerProxy
{
private readonly IHttpHeaders _real;
[DebuggerDisplay("{Value,nq}", Name = "{Key,nq}")]
internal class HttpHeader
{
private readonly KeyValuePair<string, string> _header;
public HttpHeader(KeyValuePair<string, string> header)
{
_header = header;
}
public string Value
{
get
{
return _header.Value;
}
}
public string Key
{
get
{
return _header.Key;
}
}
}
public HttpHeadersDebuggerProxy(IHttpHeaders real)
{
_real = real;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public HttpHeader[] Headers
{
get
{
return _real.Select(kvp => new HttpHeader(kvp)).ToArray();
}
}
}
}
\ No newline at end of file
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
namespace uhttpsharp.Headers
{
public class QueryStringHttpHeaders : IHttpHeaders
[DebuggerDisplay("{Count} Query String Headers")]
[DebuggerTypeProxy(typeof(HttpHeadersDebuggerProxy))]
internal class QueryStringHttpHeaders : IHttpHeaders
{
private readonly HttpHeaders _child;
private static readonly char[] Seperators = {'&', '='};
private readonly int _count;
public QueryStringHttpHeaders(string query)
{
var splittedKeyValues = query.Split(Seperators, StringSplitOptions.RemoveEmptyEntries);
......@@ -22,6 +27,7 @@ namespace uhttpsharp.Headers
values[key] = value;
}
_count = values.Count;
_child = new HttpHeaders(values);
}
......@@ -41,5 +47,13 @@ namespace uhttpsharp.Headers
{
return GetEnumerator();
}
internal int Count
{
get
{
return _count;
}
}
}
}
\ No newline at end of file
......@@ -25,7 +25,7 @@ using uhttpsharp.Headers;
namespace uhttpsharp
{
public class HttpRequestV2 : IHttpRequest
internal class HttpRequest : IHttpRequest
{
private readonly IHttpHeaders _headers;
private readonly HttpMethods _method;
......@@ -35,7 +35,7 @@ namespace uhttpsharp
private readonly IHttpHeaders _queryString;
private readonly IHttpHeaders _post;
public HttpRequestV2(IHttpHeaders headers, HttpMethods method, string protocol, Uri uri, string[] requestParameters, IHttpHeaders queryString, IHttpHeaders post)
public HttpRequest(IHttpHeaders headers, HttpMethods method, string protocol, Uri uri, string[] requestParameters, IHttpHeaders queryString, IHttpHeaders post)
{
_headers = headers;
_method = method;
......@@ -152,7 +152,7 @@ namespace uhttpsharp
IHttpHeaders headers = new HttpHeaders(headersRaw);
IHttpHeaders post = await GetPostData(streamReader, headers);
return new HttpRequestV2(headers, httpMethod, httpProtocol, uri,
return new HttpRequest(headers, httpMethod, httpProtocol, uri,
uri.OriginalString.Split(Separators, StringSplitOptions.RemoveEmptyEntries), queryString, post);
}
private static IHttpHeaders GetQueryStringData(ref string url)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment