]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/protocol/http.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: protocol/http.h
3 // Purpose: interface of wxHTTP
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
12 wxHTTP can be used to establish a connection to an HTTP server.
14 wxHTTP can thus be used to create a (basic) HTTP @b client.
19 @see wxSocketBase, wxURL
21 class wxHTTP
: public wxProtocol
30 Destructor will close the connection if connected.
36 Connect to the HTTP server.
38 By default, connection is made to the port 80 of the specified @a host.
39 You may connect to a non-default port by specifying it explicitly using
42 Currently wxHTTP only supports IPv4.
44 For the overload taking wxSockAddress, the @a wait argument is ignored.
46 virtual bool Connect(const wxString
& host
);
47 virtual bool Connect(const wxString
& host
, unsigned short port
);
48 virtual bool Connect(const wxSockAddress
& addr
, bool wait
);
52 Returns the data attached with a field whose name is specified by @a header.
53 If the field doesn't exist, it will return an empty string and not a @NULL string.
56 The header is not case-sensitive, i.e. "CONTENT-TYPE" and "content-type"
57 represent the same header.
59 wxString
GetHeader(const wxString
& header
) const;
62 Creates a new input stream on the specified path.
64 Notice that this stream is unseekable, i.e. SeekI() and TellI() methods
67 Note that you can still know the size of the file you are getting using
68 wxStreamBase::GetSize(). However there is a limitation: in HTTP protocol,
69 the size is not always specified so sometimes @c (size_t)-1 can returned to
70 indicate that the size is unknown.
71 In such case, you may want to use wxInputStream::LastRead() method in a loop
72 to get the total size.
74 @return Returns the initialized stream. You must delete it yourself
75 once you don't use it anymore and this must be done before
76 the wxHTTP object itself is destroyed. The destructor
77 closes the network connection. The next time you will
78 try to get a file the network connection will have to
79 be reestablished, but you don't have to take care of
80 this since wxHTTP reestablishes it automatically.
84 virtual wxInputStream
* GetInputStream(const wxString
& path
);
87 Returns the HTTP response code returned by the server.
89 Please refer to RFC 2616 for the list of responses.
91 int GetResponse() const;
94 It sets data of a field to be sent during the next request to the HTTP server.
96 The field name is specified by @a header and the content by @a h_data.
97 This is a low level function and it assumes that you know what you are doing.
99 void SetHeader(const wxString
& header
, const wxString
& h_data
);
102 Returns the value of a cookie.
105 wxString
GetCookie(const wxString
& cookie
) const;
108 Returns @true if there were cookies.
110 bool HasCookies() const;
113 Set the data to be posted to the server.
115 If a non-empty string is passed to this method, the next request will
116 be an HTTP @c POST instead of the default HTTP @c GET and the data from
117 @a post_buf will be posted as the body of this request.
119 void SetPostBuffer(const wxString
& post_buf
);