Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make ResponseCode a top-level type.

  • Loading branch information...
commit e6a6c3959af94e15e15af073c6705fcf98a062ea 1 parent 7147780
@joewhite joewhite authored
View
2  uhttpsharp-demo/AboutHandler.cs
@@ -25,7 +25,7 @@ public class AboutHandler : HttpRequestHandler
{
public override HttpResponse Handle(HttpRequest httpRequest)
{
- return new HttpResponse(HttpResponse.ResponseCode.Ok,
+ return new HttpResponse(HttpResponseCode.Ok,
string.Format(
"<html><head><title>uhttpsharp</title></head><body><h1>A sample http-request-handler!</h1><hr><b>{0}</b></body></html>",
HttpServer.Instance.Banner));
View
2  uhttpsharp-demo/ErrorHandler.cs
@@ -25,7 +25,7 @@ public class ErrorHandler : HttpRequestHandler
{
public override HttpResponse Handle(HttpRequest httpRequest)
{
- return new HttpResponse(HttpResponse.ResponseCode.NotFound, "These are not the droids you are looking for.");
+ return new HttpResponse(HttpResponseCode.NotFound, "These are not the droids you are looking for.");
}
}
}
View
2  uhttpsharp-demo/IndexHandler.cs
@@ -25,7 +25,7 @@ public class IndexHandler : HttpRequestHandler
{
public override HttpResponse Handle(HttpRequest httpRequest)
{
- return new HttpResponse(HttpResponse.ResponseCode.Ok, "Welcome to the Index. ☺");
+ return new HttpResponse(HttpResponseCode.Ok, "Welcome to the Index. ☺");
}
}
}
View
4 uhttpsharp/HttpRequestProxy.cs
@@ -36,7 +36,7 @@ private HttpRequestProxy()
private HttpResponse DefaultError()
{
return new HttpResponse(
- HttpResponse.ResponseCode.NotFound,
+ HttpResponseCode.NotFound,
string.Format(
"<html><head><title>{0}</title></head><body><h1>Out of the way you nobgoblin! (404)</h1>" +
"<hr><b>{0}</b></body></html>",
@@ -45,7 +45,7 @@ private HttpResponse DefaultError()
private HttpResponse DefaultIndex()
{
return new HttpResponse(
- HttpResponse.ResponseCode.Ok,
+ HttpResponseCode.Ok,
string.Format(
"<html><head><title>{0}</title></head><body><h1>Ah, potential customer!</h1><hr><b>{0}</b></body></html>",
HttpServer.Instance.Banner));
View
19 uhttpsharp/HttpResponse.cs
@@ -39,18 +39,18 @@ public sealed class HttpResponse
public string Protocol { get; private set; }
public string ContentType { get; private set; }
public bool CloseConnection { get; private set; }
- public ResponseCode Code { get; private set; }
+ public HttpResponseCode Code { get; private set; }
private Stream ContentStream { get; set; }
- public HttpResponse(ResponseCode code, string content)
+ public HttpResponse(HttpResponseCode code, string content)
: this(code, "text/html; charset=utf-8", StringToStream(content))
{
}
public HttpResponse(string contentType, Stream contentStream)
- : this(ResponseCode.Ok, contentType, contentStream)
+ : this(HttpResponseCode.Ok, contentType, contentStream)
{
}
- private HttpResponse(ResponseCode code, string contentType, Stream contentStream)
+ private HttpResponse(HttpResponseCode code, string contentType, Stream contentStream)
{
Protocol = "HTTP/1.1";
ContentType = contentType;
@@ -84,16 +84,5 @@ public void WriteResponse(Stream stream)
ContentStream.CopyTo(stream);
ContentStream.Close();
}
-
- public enum ResponseCode
- {
- Ok = 200,
- Found = 302,
- SeeOther = 303,
- BadRequest = 400,
- NotFound = 404,
- InternalServerError = 500,
- ServerBusy = 502,
- }
}
}
View
15 uhttpsharp/HttpResponseCode.cs
@@ -0,0 +1,15 @@
+// ReSharper disable UnusedMember.Global
+
+namespace uhttpsharp
+{
+ public enum HttpResponseCode
+ {
+ Ok = 200,
+ Found = 302,
+ SeeOther = 303,
+ BadRequest = 400,
+ NotFound = 404,
+ InternalServerError = 500,
+ ServerBusy = 502,
+ }
+}
View
1  uhttpsharp/uhttpsharp.csproj
@@ -50,6 +50,7 @@
<Compile Include="HttpResponse.cs" />
<Compile Include="HttpServer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="HttpResponseCode.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Please sign in to comment.
Something went wrong with that request. Please try again.