Skip to content
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);

};
}
}