base/libs/qdecoder/qCgiRequest.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include "qDecoder.h"
#include "qInternal.h"

Include dependency graph for qCgiRequest.c:

Go to the source code of this file.

Defines

#define _Q_MULTIPART_CHUNK_SIZE

FunctionsTitleTestFour

char * qCgiRequestGetQueryString (const char *query_type)
Q_ENTRYqCgiRequestParse (Q_ENTRY *request)
Q_ENTRYqCgiRequestParseCookies (Q_ENTRY *request)
Q_ENTRYqCgiRequestParseOption (bool filemode, const char *basepath, int clearold)
Q_ENTRYqCgiRequestParseQueries (Q_ENTRY *request, const char *method)


Detailed Description

Web Query & Cookie Handling API

qDecoder supports parsing

Anyway you don't care about this. You don't need to know which method (COOKIE/GET/POST) is used for sending data.

   [HTML sample]
   <form action="your_program.cgi">
     <input type="text" name="color">
     <input type="submit">
   </form>

   [Your Source]
   Q_ENTRY *req = qCgiRequestParse(NULL);
   const char *color = qEntryGetStr(req, "color");
   printf("color = %s\n", color);
   qEntryFree(req);

The storing sequence is (1)COOKIE (2)GET (3)POST. Thus if same query names (which are sent by different method) exist, COOKIE query will be returned.

If you would like to get POST queries only. See below sample codes.

   Q_ENTRY *req = qCgiRequestParseQueries(NULL, "POST");
   const char *color = qEntryGetStr(req, "color");
   printf("color = %s\n", color);

If you would like to get POST and COOKIE queries only. See below sample codes.

   Q_ENTRY *req = NULL;
   req = qCgiRequestParseCookies(req);
   req = qCgiRequestParseQueries(req, "POST");
   const char *color = qEntryGetStr(req, "color");
   printf("color = %s\n", color);
   qEntryFree(req);

In case of multipart/form-data encoding(used for file uploading), qDecoder supports 2 modes for handling file uploading. I just made a name for that.

You can switch to file mode by calling qCgiRequestParseOption().
   Q_ENTRY *req = qCgiRequestParseOption(true, "/tmp", 86400);
   req = qCgiRequestParse(req);
   (...your codes here...)
   qEntryFree(req);

Basically, when file is uploaded qDecoder store it's meta information like below.

   [default mode example]
   binary = (...binary data...)
   binary.filename = hello.xls
   binary.length = 3292
   binary.contenttype = application/vnd.ms-excel

   [file mode example]
   binary = tmp/Q_7b91698bc6d6ac7eaac93e71ce729b7c/1-hello.xls
   binary.filename = hello.xls
   binary.length = 3292
   binary.contenttype = application/vnd.ms-excel
   binary.savepath = tmp/Q_7b91698bc6d6ac7eaac93e71ce729b7c/1-hello.xls

If you want to activate progress mode. Please follow below steps

Definition in file qCgiRequest.c.


Generated on Sat Nov 18 07:00:43 2017 for JSOC_Documentation by  doxygen 1.5.7.1