From 75d1905b4107ce650b2b5ded522b145f240af69c Mon Sep 17 00:00:00 2001 From: kpko Date: Mon, 22 Apr 2013 21:30:49 +0300 Subject: [PATCH 1/2] Update Request.h to include a new Body-property --- CefSharp/Request.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CefSharp/Request.h b/CefSharp/Request.h index e6ddb932ab..85d101e604 100644 --- a/CefSharp/Request.h +++ b/CefSharp/Request.h @@ -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^ GetHeaders(); void SetHeaders(IDictionary^ headers); }; @@ -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^ GetHeaders(); virtual void SetHeaders(IDictionary^ headers); }; -} \ No newline at end of file +} From fcc20d3fd794e9346800b17a5c9c7ec25b31978d Mon Sep 17 00:00:00 2001 From: kpko Date: Mon, 22 Apr 2013 21:32:45 +0300 Subject: [PATCH 2/2] Update Request.cpp to include a getter for "Body" --- CefSharp/Request.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/CefSharp/Request.cpp b/CefSharp/Request.cpp index 88ff851fac..d84891d11d 100644 --- a/CefSharp/Request.cpp +++ b/CefSharp/Request.cpp @@ -24,6 +24,36 @@ namespace CefSharp { return toClr(_wrappedRequest->GetMethod()); } + + String^ CefRequestWrapper::Body::get() + { + CefPostData::ElementVector ev; + + CefRefPtr 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^ CefRequestWrapper::GetHeaders() { @@ -55,4 +85,4 @@ namespace CefSharp _wrappedRequest->SetHeaderMap(hm); } -} \ No newline at end of file +}