Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Body of request in custom scheme handler (code) #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion CefSharp/Request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,36 @@ namespace CefSharp
{
return toClr(_wrappedRequest->GetMethod());
}

String^ CefRequestWrapper::Body::get()
{
CefPostData::ElementVector ev;

CefRefPtr<CefPostData> data = _wrappedRequest->GetPostData();

if(data.get() != nullptr) {
data.get()->GetElements(ev);

for (CefPostData::ElementVector::iterator it = ev.begin(); it != ev.end(); ++it)
{
CefPostDataElement *el = it->get();

if(el->GetType() == PDE_TYPE_BYTES)
{
size_t count = el->GetBytesCount();
char* bytes = new char[count];

el->GetBytes(count, bytes);

return gcnew String(bytes, 0, count);
} else if(el->GetType() == PDE_TYPE_FILE) {
return toClr(el->GetFile());
}
}
}

return nullptr;
}

IDictionary<String^, String^>^ CefRequestWrapper::GetHeaders()
{
Expand Down Expand Up @@ -55,4 +85,4 @@ namespace CefSharp

_wrappedRequest->SetHeaderMap(hm);
}
}
}
4 changes: 3 additions & 1 deletion CefSharp/Request.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace CefSharp
{
property String^ Url { String^ get(); void set(String^ url); }
property String^ Method { String^ get(); }
property String^ Body { String^ get(); }
IDictionary<String^, String^>^ GetHeaders();
void SetHeaders(IDictionary<String^, String^>^ headers);
};
Expand All @@ -23,8 +24,9 @@ namespace CefSharp
public:
virtual property String^ Url { String^ get(); void set(String^ url); }
virtual property String^ Method { String^ get(); }
virtual property String^ Body { String^ get(); }
virtual IDictionary<String^, String^>^ GetHeaders();
virtual void SetHeaders(IDictionary<String^, String^>^ headers);

};
}
}