mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
reference: ScgiHello removed
git-svn-id: svn://ultimatepp.org/upp/trunk@5381 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
05252bf8b6
commit
a0f7972d4b
6 changed files with 0 additions and 182 deletions
|
|
@ -1,78 +0,0 @@
|
|||
#include <Core/Core.h>
|
||||
#include <Web/Web.h>
|
||||
#include <Web/ScgiServer.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
class App : public ScgiServer {
|
||||
public:
|
||||
virtual void OnAccepted();
|
||||
virtual void OnRequest();
|
||||
virtual void OnClosed();
|
||||
|
||||
private:
|
||||
void HelloViaGet();
|
||||
void HelloViaPost();
|
||||
|
||||
public:
|
||||
App(int port = 8787) : ScgiServer(port) {}
|
||||
};
|
||||
|
||||
void App::OnAccepted()
|
||||
{
|
||||
Cout() << "Accepted connection from client " << FormatIP(clientIP) << "\n";
|
||||
}
|
||||
|
||||
void App::HelloViaGet()
|
||||
{
|
||||
Write(Format("Hello, %s!\r\n", query["NAME"]));
|
||||
}
|
||||
|
||||
void App::HelloViaPost()
|
||||
{
|
||||
Write(Format("Hello, %s!\r\n", post["NAME"]));
|
||||
}
|
||||
|
||||
void App::OnRequest()
|
||||
{
|
||||
Write("Content-Type: text/plain\r\n\r\n");
|
||||
Write("Message:\r\n");
|
||||
|
||||
//
|
||||
// In a real app one should look at the server variable 'SCRIPT_NAME' to see:
|
||||
// * /scgi/hello
|
||||
// * /scgi/hello-form
|
||||
//
|
||||
// That method would be used for better application based
|
||||
// request dispatching vs. HasPostData()
|
||||
//
|
||||
|
||||
if (HasPostData()) {
|
||||
HelloViaPost();
|
||||
|
||||
Write("\r\nPost Data:\r\n");
|
||||
for (int i=0; i < post.GetCount(); i++)
|
||||
Write(Format("%s = '%s'\r\n", post.GetKey(i), post.GetValue(i)));
|
||||
} else
|
||||
HelloViaGet();
|
||||
|
||||
Write("\r\nQuery String:\r\n");
|
||||
for (int i=0; i < query.GetCount(); i++)
|
||||
Write(Format("%s = '%s'\r\n", query.GetKey(i), query.GetValue(i)));
|
||||
|
||||
Write("\r\nServer Variables:\r\n");
|
||||
const Vector<String> &keys = serverVars.GetKeys();
|
||||
for (int i=0; i < serverVars.GetCount(); i++)
|
||||
Write(Format("'%s' = '%s'\r\n", keys[i], serverVars.Get(keys[i])));
|
||||
}
|
||||
|
||||
void App::OnClosed()
|
||||
{
|
||||
Cout() << "Connection with " << FormatIP(clientIP) << " closed\n";
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
App app;
|
||||
app.Run();
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
description "Hello World as a SCGI Server\377";
|
||||
|
||||
uses
|
||||
Core,
|
||||
Web;
|
||||
|
||||
file
|
||||
nginx.conf,
|
||||
htdocs/index.html,
|
||||
lighttpd.conf,
|
||||
ScgiHello.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
<html>
|
||||
<head><title>ScgiHello</title></head>
|
||||
<body>
|
||||
<h1>Hello World</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="/scgi/hello?name=John">Hello John</a></li>
|
||||
<li><a href="/scgi/hello?name=Jane">Hello Jane</a></li>
|
||||
</ul>
|
||||
|
||||
<h1>Hello via POST form</h1>
|
||||
<form method="POST" action="/scgi/hello-form">
|
||||
Name:
|
||||
<!-- To show post data, add an additional field -->
|
||||
<input type="hidden" name="message" value="Hello" />
|
||||
<input type="text" name="name" />
|
||||
<input type="submit"/>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#ifndef _ScgiHello_icpp_init_stub
|
||||
#define _ScgiHello_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#include "Web/init"
|
||||
#endif
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
# Example LigHTTPD server configuration
|
||||
#
|
||||
# Run with: lighttpd -D -f lighttpd.conf
|
||||
#
|
||||
# You must also manually execute ScgiHello
|
||||
#
|
||||
|
||||
server.document-root = "./htdocs"
|
||||
server.port = 3000
|
||||
server.modules = ( "mod_scgi" )
|
||||
|
||||
mimetype.assign = (
|
||||
".html" => "text/html",
|
||||
".txt" => "text/plain",
|
||||
".jpg" => "image/jpeg",
|
||||
".png" => "image/png"
|
||||
)
|
||||
|
||||
index-file.names = ( "index.html" )
|
||||
|
||||
scgi.server= ( "/scgi/" =>
|
||||
(( "host" => "127.0.0.1",
|
||||
"port" => 8787,
|
||||
"check-local" => "disable",
|
||||
"docroot" => "/" # remote server may use it's own docroot
|
||||
))
|
||||
)
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
#
|
||||
# Simple nginx HTTP server config
|
||||
#
|
||||
# nginx runs on Windows and *nix variants
|
||||
#
|
||||
# http://nginx.org/
|
||||
#
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 8080;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root htdocs;
|
||||
}
|
||||
|
||||
location /scgi {
|
||||
scgi_pass 127.0.0.1:8787;
|
||||
scgi_param REQUEST_METHOD $request_method;
|
||||
scgi_param REQUEST_URI $request_uri;
|
||||
scgi_param QUERY_STRING $query_string;
|
||||
scgi_param CONTENT_TYPE $content_type;
|
||||
|
||||
scgi_param DOCUMENT_URI $document_uri;
|
||||
scgi_param DOCUMENT_ROOT $document_root;
|
||||
scgi_param SCGI 1;
|
||||
scgi_param SERVER_PROTOCOL $server_protocol;
|
||||
|
||||
scgi_param REMOTE_ADDR $remote_addr;
|
||||
scgi_param REMOTE_PORT $remote_port;
|
||||
scgi_param SERVER_PORT $server_port;
|
||||
scgi_param SERVER_NAME $server_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue