File: request.h

package info (click to toggle)
sms-pl 1.9.2m-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 620 kB
  • ctags: 355
  • sloc: cpp: 2,143; ansic: 1,046; perl: 272; makefile: 113; sh: 97
file content (32 lines) | stat: -rw-r--r-- 877 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef __request_h
#define __request_h

#include "socket.h"
#include "headers.h"

extern const char *HTTP_VER;

class HTTP_Request {
protected:
    char *host, *body, *w3_host, *w3host_prefix;
    int port, w3_port;
    Headers *headers;

    void ParseHeaders(Headers &hd, const char *buf, int buf_len);
    const char *JoinFormFields(Headers &fields);
    char *str2url(const char *name, char *buf);
    Socket *CreateSocket();
public:
    HTTP_Request(const char *_host, int _port = 80, const char *_w3_host = NULL, int _w3_port = 0);
    ~HTTP_Request();

    Headers *GetData(const char *path, int retr_body = 1);
    Headers *PostData(const char *path, Headers &fields);

    void ReplaceHeader(const char *name, const char *value);
    void AddHeader(const char *name, const char *value);
    const char *Header(const char *name);
    const char *GetBody();
};

#endif