File: setmethod.cc

package info (click to toggle)
bobcat 3.01.00-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,612 kB
  • sloc: cpp: 12,107; makefile: 8,055; perl: 401; sh: 329
file content (44 lines) | stat: -rw-r--r-- 1,158 bytes parent folder | download | duplicates (5)
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
33
34
35
36
37
38
39
40
41
42
43
44
#include "cgi.ih"

void CGI::setMethod()
{
    char const *cp = (*this)["REQUEST_METHOD"];

    if (cp)
    {
        string meth(cp);

        if (meth == "GET")
        {
            d_method = GET;
            return;
        }
        if (meth == "POST")
        {
            if ((cp = (*this)["CONTENT_LENGTH"]))
                d_contentLength = A2x(cp);

            if ((cp = (*this)["CONTENT_TYPE"]) != 0)
            {
                string type(cp);
                string::size_type pos;

                if 
                (
                    type.find("multipart/form-data") == 0 
                    &&
                    (pos = type.find("boundary=")) != string::npos
                )
                {                               // don't count trailing \0
                    d_boundary = type.substr(pos + sizeof("boundary=") - 1); 
                    d_boundary.insert(0, "--"); // actual boundary has two
                                                // additional - chars
                }
            }
            d_method = POST;
            return;
        }
    }
    d_status = "GET/POST REQUEST_METHOD not found";
}