/[winpt]/trunk/Include/wptHTTP.h
ViewVC logotype

Annotation of /trunk/Include/wptHTTP.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 200 - (hide annotations)
Mon Apr 17 09:12:50 2006 UTC (18 years, 10 months ago) by twoaday
File MIME type: text/plain
File size: 3001 byte(s)
2006-04-16  Timo Schulz  <ts@g10code.de>
 
        * wptHTTP.cpp (getErrorCode): New.
        (connect): Store winsock error code.
        * wptGPGMEData.cpp (is_armor_header): New.
        * wptGPG.cpp (check_gnupg_engine): Free context.
        (gnupg_backup_keyrings): Do not use global vars.
        * wptGPGUtil.cpp (gpg_export_seckey): Export in ascii format.
         
2006-04-15  Timo Schulz  <ts@g10code.de>
 
        * wptKeyManager.cpp (km_get_key): New.
        (km_key_show_revoc_info): New.
        * wptKeyRevokeDlg.cpp (key_revoke_dlg): Cleanups.
        (on_init_dialog): New.
        * wptKeyManagerDlg.cpp (key_manager_dlg_proc): Factour
        out some common code and use km_get_key() instead.
        * wptKeyEditDlgs.cpp (do_init_keylist): Change second
        param type. Change all callers.
        * wptKeyEdit.cpp (addNotation): New.
        * wptKeyEditCB.cpp (editkey_command_handler): Remove 'step'
        param everywhere. Change all callers.


1 werner 37 /* wptHttp.h - Generic HTTP code
2 twoaday 182 * Copyright (C) 2004, 2005, 2006 Timo Schulz
3 werner 37 *
4     * This file is part of WinPT.
5     *
6     * WinPT is free software; you can redistribute it and/or
7     * modify it under the terms of the GNU General Public License
8     * as published by the Free Software Foundation; either version 2
9     * of the License, or (at your option) any later version.
10     *
11     * WinPT is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14     * General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with WinPT; if not, write to the Free Software Foundation,
18     * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19     */
20    
21     #ifndef WPT_HTTP_H
22     #define WPT_HTTP_H
23    
24     /* HTTP status codes. */
25     enum http_statcode_t {
26     HTTP_STAT_NONE = 0,
27     HTTP_STAT_200 = 200, /* OK */
28 twoaday 182 HTTP_STAT_201 = 201, /* Created */
29 werner 37 HTTP_STAT_301 = 301, /* Moved Permanently */
30     HTTP_STAT_302 = 302, /* Moved Temporarily */
31     HTTP_STAT_400 = 400, /* Bad Request */
32 twoaday 182 HTTP_STAT_401 = 401, /* Unauthorized */
33 werner 37 HTTP_STAT_403 = 403, /* Forbidden */
34     HTTP_STAT_404 = 404, /* Not Found */
35     HTTP_STAT_405 = 405, /* Method Not Allowed */
36     };
37    
38 twoaday 182
39 werner 37 /* HTTP header list. */
40     struct http_head_s {
41     struct http_head_s * next;
42     int flags;
43     char d[1];
44     };
45 twoaday 182 typedef struct http_head_s *http_head_t;
46 werner 37
47 twoaday 182 class wHTTP {
48     public:
49     /* HTTP methods. */
50     enum { HTTP_GET, HTTP_HEAD, HTTP_PUT, HTTP_POST };
51    
52     private:
53     http_head_t req_headers;
54     http_head_t resp_headers;
55 werner 37 int fd;
56 twoaday 182 int statcode;
57     char *host;
58     int port;
59     char *url;
60     int nleft;
61     int method;
62     int ver;
63 twoaday 200 int error;
64 werner 37
65 twoaday 182 private:
66     void reset (void);
67     int parseResponse (int *statcode);
68     int connect (const char *host, int port);
69     int isDataAvailable (int fd);
70     int readLine (char *buf, unsigned int nbuf, int nonblock, int *nn, int *eof);
71     void addHeader (http_head_t *root, const char *val);
72     bool findHeader (http_head_t root,
73     const char *name, const char **val);
74     int parseHeaders (http_head_t *r_head);
75 werner 37
76 twoaday 182 int extractHostInfo (const char *url, char **host, char **new_url);
77     int sendRequest (const char *host, int port, const char *url);
78 werner 37
79 twoaday 182 public:
80     wHTTP ();
81     wHTTP (const char *url);
82     wHTTP (const char *host, int port, const char *url);
83     ~wHTTP ();
84    
85     void setVersion (int ver);
86 twoaday 200 int getErrorCode (void);
87 twoaday 182 int getStatusCode (void);
88     unsigned int getContentLength (void);
89     const char *getContentType (void);
90 werner 37
91 twoaday 182 int addRequestHeader (const char *name, const char *val);
92     int addRequestHeader (const char *name, unsigned int val);
93    
94     int write (const void *buf, unsigned int buflen);
95     int read (void *buf, unsigned int buflen);
96     int readData (FILE *out);
97    
98     int get (const char *url);
99     int head (const char *url);
100     };
101    
102 werner 37 #endif /* WPT_HTTP_H */

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26