Z
Z
Zaur Ashurbekov2017-10-26 22:09:50
linux
Zaur Ashurbekov, 2017-10-26 22:09:50

How to parse http request when working with fastCGI?

Hello dear Toaster! And here again I need your help.
There is a C++ program on Linux that should work with HTTP requests. After reading an article from Habr Web application in C / C ++ using FastCGI , I decided to make a bunch of nginx + fcgi using the libfcgi.lib library. Everything seemed to work, but now the question is how to process the http request in the program itself?
What do you need? Let's say we have a GET request

mysite.ru/model/submodel?param1=value1&param2=value2

After processing this request, there should be the following data
request type: get
address: ["model", "submodel"]
parameters: {"param1": "value1", "param2":"value2"}
In my opinion, you will have to parse data with parameter
FCGX_GetParam("REQUEST_METHOD", request.envp)
If this is a get request, then look for the parameters there, if not, climb into request.in
But, as always, something tells me that the good guys from the Internet have already implemented all this, I just can’t find it . Has anyone come across a similar issue?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2017-10-26
@Stalker_RED

Of course implemented. It's called an http server, and there are plenty of them, to put it mildly.
The most common are apache and nginx. It's probably an overkill for your purposes, but now that you know what "it" is called, I think you'll be able to pick up something.
There are also separate http libraries .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question