简体   繁体   English

如何使超链接调用相同的C ++ CGI进程

[英]How to make hyperlinks call same C++ CGI process

So my C++ CGI program generates some html-page with several links. 因此,我的C ++ CGI程序会生成带有多个链接的html页面。 How can I make within the same C++ process that after clicking this links will be displayed some others pages with content depending on what hyperlink was clicked? 如何在相同的C ++流程中使单击此链接后将显示其他页面,这些页面的内容取决于所单击的超链接?

For now I just have variant that there will be other C++ CGI program that will read URL param with getenv, and this param will be different for every link from my first page. 现在,我只是有一个变种,那就是还有其他C ++ CGI程序将使用getenv读取URL参数,并且该参数对于首页中的每个链接都会有所不同。 But I believe there must be a way of doing this with one C++ process. 但是我相信必须有一种方法可以通过一个C ++进程来实现。

You are trying to store session information in the memory of your CGI program. 您正在尝试将会话信息存储在CGI程序的内存中。 CGI protocol doesn't allow this by itself . CGI协议本身不会允许这样。 You must store session information somewhere else. 您必须将会话信息存储在其他地方。 Your options are: 您的选择是:

  • Output HTML where result of your calculations is embedded in URLs, so that next execution will see those results (if that information is sensitive, this is a security flaw - you may overcome this with safe encryption). 输出HTML,其中将计算结果嵌入URL中,以便下次执行时可以看到这些结果(如果该信息敏感,则这是一个安全漏洞-您可以通过安全加密来克服此缺陷)。
  • Store results outside your C++ program memory (a file?). 将结果存储在C ++程序存储器之外(文件?)。 Then output a cookie or embed a session identifier in the URLs. 然后输出Cookie或在URL中嵌入会话标识符。 In the next execution, you perform a lookup with session identifier then load those results from your server. 在下一次执行中,您将使用会话标识符执行查找,然后从服务器加载这些结果。 You must take care to free old data to avoid space exhaustion. 您必须小心释放旧数据,以避免空间耗尽。
  • Turn your C++ application into a web server! 将您的C ++应用程序变成Web服务器! Your C++ application will answer HTTP requests (it will not be only a CGI application). 您的C ++应用程序将回答HTTP请求(不仅是CGI应用程序)。 That may be overkill, but might be necessary. 那可能是矫kill过正,但可能是必要的。 I think there are free open source libraries that helps on that, or you can develop an Apache (httpd) module. 我认为有免费的开源库对此有所帮助,或者您可以开发一个Apache(httpd)模块。

Hope that answers your question! 希望这能回答你的问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM