2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include "WebNonCopyable.h"
36 #include "WebString.h"
39 #if WEBKIT_IMPLEMENTATION
40 namespace WebCore { class FormData; }
41 namespace WTF { template <typename T> class PassRefPtr; }
46 class WebHTTPBodyPrivate;
51 enum Type { TypeData, TypeFile, TypeBlob } type;
55 long long fileLength; // -1 means to the end of the file.
56 double modificationTime;
60 ~WebHTTPBody() { reset(); }
62 WebHTTPBody() : m_private(0) { }
63 WebHTTPBody(const WebHTTPBody& b) : m_private(0) { assign(b); }
64 WebHTTPBody& operator=(const WebHTTPBody& b)
70 WEBKIT_EXPORT void initialize();
71 WEBKIT_EXPORT void reset();
72 WEBKIT_EXPORT void assign(const WebHTTPBody&);
74 bool isNull() const { return !m_private; }
76 // Returns the number of elements comprising the http body.
77 WEBKIT_EXPORT size_t elementCount() const;
79 // Sets the values of the element at the given index. Returns false if
80 // index is out of bounds.
81 WEBKIT_EXPORT bool elementAt(size_t index, Element&) const;
83 // Append to the list of elements.
84 WEBKIT_EXPORT void appendData(const WebData&);
85 WEBKIT_EXPORT void appendFile(const WebString&);
86 // Passing -1 to fileLength means to the end of the file.
87 WEBKIT_EXPORT void appendFileRange(const WebString&, long long fileStart, long long fileLength, double modificationTime);
88 WEBKIT_EXPORT void appendBlob(const WebURL&);
90 // Identifies a particular form submission instance. A value of 0 is
91 // used to indicate an unspecified identifier.
92 WEBKIT_EXPORT long long identifier() const;
93 WEBKIT_EXPORT void setIdentifier(long long);
95 WEBKIT_EXPORT bool containsPasswordData() const;
96 WEBKIT_EXPORT void setContainsPasswordData(bool);
98 #if WEBKIT_IMPLEMENTATION
99 WebHTTPBody(const WTF::PassRefPtr<WebCore::FormData>&);
100 WebHTTPBody& operator=(const WTF::PassRefPtr<WebCore::FormData>&);
101 operator WTF::PassRefPtr<WebCore::FormData>() const;
105 void assign(WebHTTPBodyPrivate*);
106 void ensureMutable();
107 WebHTTPBodyPrivate* m_private;
110 } // namespace WebKit