Move Response class into c# land

This commit is contained in:
amaitland
2014-11-17 13:00:27 +10:00
parent cb8385c1b3
commit 02da2d5d26
7 changed files with 61 additions and 109 deletions
-2
View File
@@ -223,7 +223,6 @@
<ClCompile Include="Internals\CookieVisitor.cpp" />
<ClCompile Include="Internals\CefRequestWrapper.cpp" />
<ClCompile Include="Internals\DownloadAdapter.cpp" />
<ClCompile Include="Internals\RequestResponse.cpp" />
<ClCompile Include="Internals\StringVisitor.cpp" />
<ClCompile Include="SchemeHandlerResponse.cpp" />
<ClCompile Include="SchemeHandlerWrapper.cpp" />
@@ -251,7 +250,6 @@
<ClInclude Include="Internals\StringVisitor.h" />
<ClInclude Include="MouseButtonType.h" />
<ClInclude Include="ManagedCefBrowserAdapter.h" />
<ClInclude Include="Internals\RequestResponse.h" />
<ClInclude Include="CefSettings.h" />
<ClInclude Include="SchemeHandlerResponse.h" />
<ClInclude Include="SchemeHandlerWrapper.h" />
@@ -41,9 +41,6 @@
<ClCompile Include="Internals\CefWebPluginInfoWrapper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Internals\RequestResponse.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Internals\StringVisitor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -112,9 +109,6 @@
<ClInclude Include="Internals\CefWebPluginInfoWrapper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Internals\RequestResponse.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Internals\StringVisitor.h">
<Filter>Header Files</Filter>
</ClInclude>
+1 -1
View File
@@ -7,13 +7,13 @@
#include "Internals/CefRequestWrapper.h"
#include "Internals/CefWebPluginInfoWrapper.h"
#include "Internals/JavascriptBinding/BindingHandler.h"
#include "Internals/RequestResponse.h"
#include "ClientAdapter.h"
#include "Cef.h"
#include "DownloadAdapter.h"
#include "StreamAdapter.h"
using namespace std;
using namespace CefSharp;
using namespace CefSharp::Internals::JavascriptBinding;
namespace CefSharp
@@ -1,49 +0,0 @@
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "Stdafx.h"
#include "RequestResponse.h"
namespace CefSharp
{
namespace Internals
{
void Response::Cancel()
{
_action = ResponseAction::Cancel;
}
void Response::Redirect(String^ url)
{
_redirectUrl = url;
_action = ResponseAction::Redirect;
}
void Response::RespondWith(Stream^ stream, String^ mimeType)
{
RespondWith(stream, mimeType, "OK", 200, nullptr);
}
void Response::RespondWith(Stream^ stream, String^ mimeType, String^ statusText, int statusCode, NameValueCollection^ responseHeaders)
{
if (String::IsNullOrEmpty(mimeType))
{
throw gcnew ArgumentException("must provide a mime type", "mimeType");
}
if (stream == nullptr)
{
throw gcnew ArgumentNullException("stream");
}
_responseStream = stream;
_mimeType = mimeType;
_statusText = statusText;
_statusCode = statusCode;
_responseHeaders = responseHeaders;
_action = ResponseAction::Respond;
}
}
}
-51
View File
@@ -1,51 +0,0 @@
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#pragma once
#include "Stdafx.h"
using namespace System;
using namespace System::IO;
using namespace System::Collections::Specialized;
using namespace CefSharp;
namespace CefSharp
{
namespace Internals
{
private ref class Response : IResponse
{
IRequest^ _request;
Stream^ _responseStream;
String^ _mimeType;
String^ _redirectUrl;
ResponseAction _action;
String^ _statusText;
int _statusCode;
NameValueCollection^ _responseHeaders;
internal:
Response() : _action(ResponseAction::Continue)
{
}
property Stream^ ResponseStream { Stream^ get() { return _responseStream; } }
property String^ MimeType { String^ get() { return _mimeType; } }
property String^ StatusText { String^ get() { return _statusText; } }
property int StatusCode { int get() { return _statusCode; } }
property NameValueCollection^ ResponseHeaders { NameValueCollection^ get() { return _responseHeaders; } }
property String^ RedirectUrl { String^ get() { return _redirectUrl; } }
property ResponseAction Action { ResponseAction get() { return _action; } }
public:
virtual void Cancel();
virtual void Redirect(String^ url);
virtual void RespondWith(Stream^ stream, String^ mimeType);
virtual void RespondWith(Stream^ stream, String^ mimeType, String^ statusText, int statusCode, NameValueCollection^ responseHeaders);
};
}
}
+1
View File
@@ -108,6 +108,7 @@
<Compile Include="Internals\BrowserProcessServiceHost.cs" />
<Compile Include="Internals\WCFExtensions.cs" />
<Compile Include="KeyType.cs" />
<Compile Include="Response.cs" />
<Compile Include="ResponseAction.cs" />
<Compile Include="TransitionType.cs" />
<Compile Include="NavStateChangedEventArgs.cs" />
+59
View File
@@ -0,0 +1,59 @@
using System;
using System.Collections.Specialized;
using System.IO;
namespace CefSharp
{
public class Response : IResponse
{
public Stream ResponseStream { get;private set; }
public String MimeType { get; private set; }
public String StatusText { get; private set; }
public int StatusCode { get; private set; }
public NameValueCollection ResponseHeaders { get; private set; }
public String RedirectUrl { get; private set; }
public ResponseAction Action { get; private set; }
public Response()
{
Action = ResponseAction.Continue;
}
public void Cancel()
{
Action = ResponseAction.Cancel;
}
public void Redirect(String url)
{
RedirectUrl = url;
Action = ResponseAction.Redirect;
}
public void RespondWith(Stream stream, String mimeType)
{
RespondWith(stream, mimeType, "OK", 200, null);
}
public void RespondWith(Stream stream, String mimeType, String statusText, int statusCode, NameValueCollection responseHeaders)
{
if (string.IsNullOrEmpty(mimeType))
{
throw new ArgumentException("must provide a mime type", "mimeType");
}
if (stream == null)
{
throw new ArgumentNullException("stream");
}
ResponseStream = stream;
MimeType = mimeType;
StatusText = statusText;
StatusCode = statusCode;
ResponseHeaders = responseHeaders;
Action = ResponseAction.Respond;
}
}
}