cgi-fake.sh 741 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. export cgi="shaarligo.cgi"
  3. go fmt *.go && go build -ldflags "-s" -o "${cgi}" || exit 1
  4. export SCRIPT_NAME="/sub/${cgi}"
  5. export SERVER_PROTOCOL="HTTP/1.1"
  6. export HTTP_HOST="example.com"
  7. get() {
  8. export REQUEST_METHOD="GET"
  9. export PATH_INFO="${1}"
  10. time "../${cgi}"
  11. }
  12. post() {
  13. export REQUEST_METHOD="POST"
  14. export CONTENT_TYPE="application/x-www-form-urlencoded"
  15. export PATH_INFO="${1}"
  16. export CONTENT_LENGTH="${2}"
  17. time "../${cgi}"
  18. }
  19. rm -rf "tmp" 2>/dev/null
  20. mkdir "tmp" && cd "tmp" && time "../${cgi}"
  21. post "/config" 119 <<EOF
  22. title=A&setlogin=B&setpassword=123456789012&import_shaarli_url=&import_shaarli_setlogin=&import_shaarli_setpassword=
  23. EOF
  24. export QUERY_STRING="?post=www.heise.de"
  25. get
  26. # get "/config"