2010-10-03 23:04:50 +02:00
|
|
|
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef _REQUEST_IMPL_H
|
|
|
|
#define _REQUEST_IMPL_H
|
|
|
|
|
|
|
|
#include "../include/cef.h"
|
|
|
|
#include "net/base/upload_data.h"
|
|
|
|
#include "net/http/http_request_headers.h"
|
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebHTTPBody.h"
|
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h"
|
|
|
|
|
2010-12-16 22:54:42 +01:00
|
|
|
namespace net {
|
2010-10-03 23:04:50 +02:00
|
|
|
class URLRequest;
|
2010-12-16 22:54:42 +01:00
|
|
|
};
|
2010-10-03 23:04:50 +02:00
|
|
|
|
|
|
|
// Implementation of CefRequest
|
|
|
|
class CefRequestImpl : public CefThreadSafeBase<CefRequest>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CefRequestImpl();
|
|
|
|
~CefRequestImpl() {}
|
|
|
|
|
2010-11-22 18:49:46 +01:00
|
|
|
virtual CefString GetURL();
|
|
|
|
virtual void SetURL(const CefString& url);
|
|
|
|
virtual CefString GetMethod();
|
|
|
|
virtual void SetMethod(const CefString& method);
|
2010-10-03 23:04:50 +02:00
|
|
|
virtual CefRefPtr<CefPostData> GetPostData();
|
|
|
|
virtual void SetPostData(CefRefPtr<CefPostData> postData);
|
|
|
|
virtual void GetHeaderMap(HeaderMap& headerMap);
|
|
|
|
virtual void SetHeaderMap(const HeaderMap& headerMap);
|
2010-11-22 18:49:46 +01:00
|
|
|
virtual void Set(const CefString& url,
|
|
|
|
const CefString& method,
|
2010-10-03 23:04:50 +02:00
|
|
|
CefRefPtr<CefPostData> postData,
|
|
|
|
const HeaderMap& headerMap);
|
|
|
|
|
2010-12-16 22:54:42 +01:00
|
|
|
void Set(net::URLRequest* request);
|
2010-10-03 23:04:50 +02:00
|
|
|
|
|
|
|
static void GetHeaderMap(const net::HttpRequestHeaders& headers,
|
|
|
|
HeaderMap& map);
|
|
|
|
static void GetHeaderMap(const WebKit::WebURLRequest& request,
|
|
|
|
HeaderMap& map);
|
|
|
|
static void SetHeaderMap(const HeaderMap& map,
|
|
|
|
WebKit::WebURLRequest& request);
|
|
|
|
|
|
|
|
static std::string GenerateHeaders(const HeaderMap& map);
|
|
|
|
static void ParseHeaders(const std::string& header_str, HeaderMap& map);
|
|
|
|
|
|
|
|
protected:
|
2010-11-22 18:49:46 +01:00
|
|
|
CefString url_;
|
|
|
|
CefString method_;
|
2010-10-03 23:04:50 +02:00
|
|
|
CefRefPtr<CefPostData> postdata_;
|
|
|
|
HeaderMap headermap_;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Implementation of CefPostData
|
|
|
|
class CefPostDataImpl : public CefThreadSafeBase<CefPostData>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CefPostDataImpl();
|
|
|
|
~CefPostDataImpl() {}
|
|
|
|
|
|
|
|
virtual size_t GetElementCount();
|
|
|
|
virtual void GetElements(ElementVector& elements);
|
|
|
|
virtual bool RemoveElement(CefRefPtr<CefPostDataElement> element);
|
|
|
|
virtual bool AddElement(CefRefPtr<CefPostDataElement> element);
|
|
|
|
virtual void RemoveElements();
|
|
|
|
|
|
|
|
void Set(net::UploadData& data);
|
|
|
|
void Get(net::UploadData& data);
|
|
|
|
void Set(const WebKit::WebHTTPBody& data);
|
|
|
|
void Get(WebKit::WebHTTPBody& data);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ElementVector elements_;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Implementation of CefPostDataElement
|
|
|
|
class CefPostDataElementImpl : public CefThreadSafeBase<CefPostDataElement>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CefPostDataElementImpl();
|
|
|
|
~CefPostDataElementImpl();
|
|
|
|
|
|
|
|
virtual void SetToEmpty();
|
2010-11-22 18:49:46 +01:00
|
|
|
virtual void SetToFile(const CefString& fileName);
|
2010-10-03 23:04:50 +02:00
|
|
|
virtual void SetToBytes(size_t size, const void* bytes);
|
|
|
|
virtual Type GetType();
|
2010-11-22 18:49:46 +01:00
|
|
|
virtual CefString GetFile();
|
2010-10-03 23:04:50 +02:00
|
|
|
virtual size_t GetBytesCount();
|
|
|
|
virtual size_t GetBytes(size_t size, void* bytes);
|
|
|
|
|
|
|
|
void* GetBytes() { return data_.bytes.bytes; }
|
|
|
|
|
|
|
|
void Set(const net::UploadData::Element& element);
|
|
|
|
void Get(net::UploadData::Element& element);
|
|
|
|
void Set(const WebKit::WebHTTPBody::Element& element);
|
|
|
|
void Get(WebKit::WebHTTPBody::Element& element);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Type type_;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
void* bytes;
|
|
|
|
size_t size;
|
|
|
|
} bytes;
|
2010-11-22 18:49:46 +01:00
|
|
|
cef_string_t filename;
|
2010-10-03 23:04:50 +02:00
|
|
|
} data_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _REQUEST_IMPL_H
|