Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5938275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:39:43+00:00 2026-05-22T15:39:43+00:00

I am writing a C CGI program For GET requests, I assume all the

  • 0

I am writing a C CGI program

For GET requests, I assume all the information is somehow stored in getenv(). My question is, what does this array look like a most basic CGI request from the webserver. With two prarameters e.g. username= and password=.

For POST request, I am unsure. I’ve read that stuff is handled on standard input. What do these lines that are passed to a CGI program via standard input (from the webserver) look like?

Pointing me to a verbose RFC is unhelpful.

Any book? I am specifically interested in the low-level details of the protocol. I already know how to write CGI apps with helper libs… I just need to know the semantics of those helper libs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:39:44+00:00Added an answer on May 22, 2026 at 3:39 pm

    envp is not standard (well, not ISO C or C++ standard anyway, though POSIX may have something for it).

    However, envp is pretty much the same format as argv escept it doesn’t have a controlling argc to limit it.

    Each envp[x] will be of the form "key=value" where the key is the environment variable name and the value is its value, surprisingly enough πŸ™‚

    You should process the elements sequentially until you get a NULL pointer, something like:

    #include <stdio.h>
    int main (int argc, char *argv[], char *envp[]) {
        int i = 0;
        while (envp[i] != NULL)
            printf ("[%s]\n", envp[i++]);
        return 0;
    }
    

    The Wikipedia entry for CGI gives further details, hopefully without swamping you with too much information like a verbose RFC would.

    Copying the relevant stuff to make this answer self-contained:

    • Server specific variables:
      • SERVER_SOFTWARE β€” name/version of HTTP server.
      • SERVER_NAME β€” host name of the server, may be dot-decimal IP address.
      • GATEWAY_INTERFACE β€” CGI/version.
    • Request specific variables:
      • SERVER_PROTOCOL β€” HTTP/version.
      • SERVER_PORT β€” TCP port (decimal).
      • REQUEST_METHOD β€” name of HTTP method (see above).
      • PATH_INFO β€” path suffix, if appended to URL after program name and a slash.
      • PATH_TRANSLATED β€” corresponding full path as supposed by server, if PATH_INFO is present.
      • SCRIPT_NAME β€” relative path to the program, like /cgi-bin/script.cgi.
      • QUERY_STRING β€” the part of URL after ? character. May be composed of *name=value pairs separated with ampersands (such as var1=val1&var2=val2…) when used to submit form data transferred via GET method as defined by HTML application/x-www-form-urlencoded.
      • REMOTE_HOST β€” host name of the client, unset if server did not perform such lookup.
      • REMOTE_ADDR β€” IP address of the client (dot-decimal).
      • AUTH_TYPE β€” identification type, if applicable.
      • REMOTE_USER used for certain AUTH_TYPEs.
      • REMOTE_IDENT β€” see ident, only if server performed such lookup.
      • CONTENT_TYPE β€” MIME type of input data if PUT or POST method are used, as provided via HTTP header.
      • CONTENT_LENGTH β€” similarly, size of input data (decimal, in octets) if provided via HTTP header.
      • Variables passed by user agent (HTTP_ACCEPT, HTTP_ACCEPT_LANGUAGE, HTTP_USER_AGENT, HTTP_COOKIE and possibly others) contain values of corresponding HTTP headers and therefore have the same sense.

    Beyond that level of detail, you’re probably going to have to look into the RFCs, I’m afraid. A search for RFC3875 on Google should locate it.

    Specifically, for POST, the environment variables are included before the first blank line of the request (the one that introduces the message body). They have the form:

    Content-Type: application/wonderful_app_by_pax
    Content-Length: 314159
    

    where the key is case-insensitive and the value follows the colon.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a JSON response from a perl/cgi program. The header's content type
I'm writing a cgi-bin program for my Sheevaplug (running the default Ubuntu install) that
This question asks about the disadvantages of 'cgi-bin based' services. As far as I
Background I am writing and using a very simple CGI-based (Perl) content management tool
Writing a JSP page, what exactly does the <c:out> do? I've noticed that the
Writing something like this using the loki library , typedef Functor<void> BitButtonPushHandler; throws a
I am writing a Bulk Mail scheduler controlled from a Perl/CGI Application and would
I have a cgi web program (in C) that prints out different error messages
I'm writing a python program. The program calculates Latin Squares using two numbers the
I am writing a query to fetch results for all the values in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.