~retropikzel/fcgi-bridge

6d15b7f323fc48806a8b0e6876aa872c335e85a4 — retropikzel 4 months ago 76dc3df
Add argument handling
5 files changed, 27 insertions(+), 7 deletions(-)

M bridge.cgi
M dist/fcgi2scgi
M src/fcgi2scgi.c
D test.fcgi
M test/scgiclient/src/main.scm
M bridge.cgi => bridge.cgi +1 -1
@@ 11,7 11,7 @@ PORT=$((3000 + $RANDOM % 1000))

/usr/www/users/retrops/programs/bin/gosh -I ./schubert main.scm $PORT > scgi_bridge_output.txt 2>&1 &
sleep 2
exec ./fcgi2scgi $PORT > fcgi2scgi_output.txt 2>&1
exec ./fcgi2scgi $PORT --development > fcgi2scgi_output.txt 2>&1




M dist/fcgi2scgi => dist/fcgi2scgi +0 -0
M src/fcgi2scgi.c => src/fcgi2scgi.c +17 -1
@@ 25,6 25,11 @@ int count_leading_spaces(char* str) {

int main(int argc, char *argv[]) {

    if(argc == 0) {
        fprintf(stderr, "No port given");
        exit(1);
    }

    char* old_message = " 72:CONTENT_LENGTH\0" "0\0SCGI\0" "1\0REQUEST_METHOD\0GET\0REQUEST_URI\0/hello\0,0:,";
    char **envpointer = NULL;
    char server_reply[4000];


@@ 54,7 59,11 @@ int main(int argc, char *argv[]) {

    while (FCGI_Accept() >= 0) {
        memset(scgi_message, 0, scgi_message_memory_size);
        puts("Content-type: text/html\r\n\r\n");
        if(argc > 2) {
            if(strcmp(argv[2], "--debug") == 0) {
                puts("Content-type: text/html\r\n\r\n");
            }
        }

        content_length = 0;
        if(getenv("CONTENT_LENGTH") != NULL) {


@@ 135,5 144,12 @@ int main(int argc, char *argv[]) {
        body = realloc(body, body_memory_size);
        scgi_message_memory_size = original_scgi_message_memory_size;
        scgi_message = realloc(scgi_message, scgi_message_memory_size);
        if(argc > 2) {
            if(strcmp(argv[2], "--development") == 0) {
                exit(0);
            } else if(strcmp(argv[2], "--debug") == 0) {
                exit(0);
            }
        }
    }
}

D test.fcgi => test.fcgi +0 -1
@@ 1,1 0,0 @@
#!/bin/bash

M test/scgiclient/src/main.scm => test/scgiclient/src/main.scm +9 -4
@@ 10,10 10,15 @@

(define no-endpoint-handler
  (lambda (request)
    (string-append ;"Content-type: text/html"
                   ;"\r\n"
                   ;"\r\n"
                   "No such endpoint")))
(string-append "Content-type: text/html"
               "\r\n"
               "\r\n"
    (parameterize
      ((current-output-port
         (open-output-string)))
      (write request)
      (get-output-string (current-output-port)))
    )))

(define hello-handler
  (lambda (request)