branch: elpa/mentor
commit cddddfcb3a1a64fd25c7da915de2f0627ea275cc
Author: Stefan Kangas <stefankan...@gmail.com>
Commit: Stefan Kangas <stefankan...@gmail.com>

    Delete bundled url-scgi.el
---
 .elpaignore            |   1 -
 Makefile               |   3 +-
 doc/scgi-protocol.txt  | 101 ---------------------------
 test/url-scgi-tests.el |  50 --------------
 url-scgi.el            | 183 -------------------------------------------------
 5 files changed, 1 insertion(+), 337 deletions(-)

diff --git a/.elpaignore b/.elpaignore
index bb4d007333..2f07259eed 100644
--- a/.elpaignore
+++ b/.elpaignore
@@ -2,5 +2,4 @@ COPYING
 Makefile
 test-rtorrent.py
 test
-doc/scgi-protocol.txt
 doc/screenshot.png
diff --git a/Makefile b/Makefile
index edc5a7dbd6..02201d0f00 100644
--- a/Makefile
+++ b/Makefile
@@ -18,9 +18,8 @@ clean:
        rm -f $(TARGET) TAGS
 
 tags:
-       etags mentor*.el url-scgi.el
+       etags mentor*.el
 
 test:
        @$(EMACS_LOAD) -l test/mentor-rpc-tests.el -f 
ert-run-tests-batch-and-exit
        @$(EMACS_LOAD) -l test/mentor-tests.el -f ert-run-tests-batch-and-exit
-       @$(EMACS_LOAD) -l test/url-scgi-tests.el -f ert-run-tests-batch-and-exit
diff --git a/doc/scgi-protocol.txt b/doc/scgi-protocol.txt
deleted file mode 100644
index 34c128005f..0000000000
--- a/doc/scgi-protocol.txt
+++ /dev/null
@@ -1,101 +0,0 @@
-SCGI: A Simple Common Gateway Interface alternative
-Neil Schemenauer <n...@python.ca>
-2008-06-23 
-
-1. Introduction
-
-    The SCGI protocol is a replacement for the Common Gateway Interface
-    (CGI) protocol.  It is a standard for applications to interface with
-    HTTP servers.  It is similar to FastCGI but is designed to be easier
-    to implement.
-
-    In this document, a string of 8-bit bytes may be written in two
-    different forms: as a series of hexadecimal numbers between angle
-    brackets, or as a sequence of ASCII characters between double quotes.
-    For example, <68 65 6c 6c 6f 20 77 6f 72 6c 64 21> is a string of
-    length 12; it is the same as the string "hello world!". Note that
-    these notations are part of this document, not part of the protocol.
-
-
-2. Protocol
-
-    The client connects to a SCGI server over a reliable stream protocol
-    allowing transmission of 8-bit bytes.  The client begins by sending a
-    request.  See section 3 for the format of the request.  When the SCGI
-    server sees the end of the request it sends back a response and closes
-    the connection.  The format of the response is not specified by this
-    protocol.
-
-
-3. Request Format
-
-    A request consists of a number of headers and a body.  The format of
-    the headers is:
-
-        headers ::= header*
-        header ::= name NUL value NUL
-        name ::= notnull+                
-        value ::= notnull*
-        notnull ::= <01> | <02> | <03> | ... | <ff>
-        NUL = <00>
-
-    Duplicate names are not allowed in the headers.  The first header
-    must have the name "CONTENT_LENGTH" and a value that is a nonempty
-    sequence of ASCII digits giving the of the body length in decimal.
-    The "CONTENT_LENGTH" header must always be present, even if its
-    value is "0".  There must also always be a header with the name
-    "SCGI" and a value of "1".  In order to facilitate the transition
-    from CGI, standard CGI environment variables should be provided as
-    SCGI headers.  
-
-    The headers are sent encoded as a netstring.  Netstring encoding is
-    explained in section 4.  The body is sent following the headers and
-    its length is specified by the "CONTENT_LENGTH" header.
-    
-
-4. Netstrings
-
-    Any string of 8-bit bytes may be encoded as [len]":"[string]",".  Here
-    [string] is the string and [len] is a nonempty sequence of ASCII
-    digits giving the length of [string] in decimal. The ASCII digits are
-    <30> for 0, <31> for 1, and so on up through <39> for 9. Extra zeros
-    at the front of [len] are prohibited: [len] begins with <30> exactly
-    when [string] is empty.
-
-    For example, the string "hello world!" is encoded as <31 32 3a 68 65
-    6c 6c 6f 20 77 6f 72 6c 64 21 2c>, i.e., "12:hello world!,". The empty
-    string is encoded as "0:,".
-    
-    [len]":"[string]"," is called a netstring. [string] is called the
-    interpretation of the netstring.
-
-
-5. Example
-
-    The web server (a SCGI client) opens a connection and sends the
-    concatenation of the following strings:
-
-        "70:"
-            "CONTENT_LENGTH" <00> "27" <00>
-            "SCGI" <00> "1" <00>
-            "REQUEST_METHOD" <00> "POST" <00>
-            "REQUEST_URI" <00> "/deepthought" <00>
-        ","
-        "What is the answer to life?"
-
-    The SCGI server sends the following response:
-
-        "Status: 200 OK" <0d 0a>
-        "Content-Type: text/plain" <0d 0a>
-        "" <0d 0a>
-        "42"
-
-    The SCGI server closes the connection. 
-
-
-6. Copyright
-
-    This document has been placed in the public domain.
-
-
-/* vim: set ai tw=74 et sw=4 sts=4: */
diff --git a/test/url-scgi-tests.el b/test/url-scgi-tests.el
deleted file mode 100644
index 05dca48e5b..0000000000
--- a/test/url-scgi-tests.el
+++ /dev/null
@@ -1,50 +0,0 @@
-;;; url-scgi-tests.el --- Test suite for url-scgi.el -*- lexical-binding: t -*-
-
-;; Copyright (C) 2016-2022 Stefan Kangas.
-
-;; Author: Stefan Kangas <stefankan...@gmail.com>
-
-;; This file is NOT part of GNU Emacs.
-
-;; Mentor is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; Mentor is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with Mentor.  If not, see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;;; Code:
-
-(require 'ert)
-(require 'url-scgi)
-
-(ert-deftest url-scgi-string-to-netstring ()
-  (should (equal (url-scgi-string-to-netstring "abcde") "5:abcde,")))
-
-(ert-deftest url-scgi-add-null-bytes ()
-  (should (equal (url-scgi-add-null-bytes "foo") "foo\^@"))
-  (should (equal (url-scgi-add-null-bytes "foo" "bar") "foo\^@bar\^@")))
-
-(ert-deftest url-scgi-make-request-header ()
-  (should (equal (url-scgi-make-request-header "foobar")
-                 "24:CONTENT_LENGTH\^@6\^@SCGI\^@1\^@,")))
-
-(ert-deftest url-scgi-create-request ()
-  (let ((url-request-data "foobar"))
-    (should (equal (url-scgi-create-request)
-                   "24:CONTENT_LENGTH\^@6\^@SCGI\^@1\^@,foobar"))))
-
-(ert-deftest url-scgi-handle-home-dir ()
-  (should (equal (url-scgi-handle-home-dir "/~/foo")
-                 (expand-file-name "~/foo")))
-  (should (equal (url-scgi-handle-home-dir "/foo") "/foo")))
-
-;;; url-scgi-tests.el ends here
diff --git a/url-scgi.el b/url-scgi.el
deleted file mode 100644
index bff17ad518..0000000000
--- a/url-scgi.el
+++ /dev/null
@@ -1,183 +0,0 @@
-;;; url-scgi.el --- SCGI Uniform Resource Locator retrieval code  -*- 
lexical-binding: t -*-
-
-;; Copyright (C) 2011-2022 Stefan Kangas.
-
-;; Author: Stefan Kangas <stefankan...@gmail.com>
-;; Version: 0.6
-;; Keywords: comm, data, processes, scgi
-;; Package-Requires: ((cl-lib "0.5"))
-
-;; This file is NOT part of GNU Emacs.
-
-;; This program is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; Support for SCGI URLs.
-;;
-;; The SCGI specification document can be found at:
-;;
-;; https://python.ca/scgi/protocol.txt
-;;
-;; This is heavily based on the url-http.el library.
-
-;;; Change Log:
-
-;; 0.6 - Documentation fixes
-
-;; 0.5 - Fix using file socket on Emacs 25
-;;       Fix cl-check-type bug on Emacs 26.1
-
-;; 0.4 - Significant code cleanups
-
-;; 0.3 - Support scgi over local socket
-
-;; 0.2 - Support Emacs 24
-
-;; 0.1 - First public version
-
-;;; Code:
-
-(require 'cl-lib)
-(require 'url-parse)
-
-(defvar url-scgi-version "0.6"
-  "The version of scgi that you're using.")
-
-(defvar url-scgi-connection-opened)
-
-(defconst url-scgi-asynchronous-p t "SCGI retrievals are asynchronous.")
-
-;; Silence byte-compiler
-(defvar url-callback-function)
-(defvar url-callback-arguments)
-(defvar url-current-object)
-(defvar url-request-data)
-
-(defun url-scgi-string-to-netstring (str)
-  "Convert string STR into a SCGI protocol netstring."
-  (format "%d:%s," (length str) str))
-
-(defun url-scgi-add-null-bytes (&rest args)
-  (apply 'concat (mapcar (lambda (a) (concat a "\000")) args)))
-
-(defun url-scgi-make-request-header (data)
-  (url-scgi-string-to-netstring
-   (url-scgi-add-null-bytes
-    "CONTENT_LENGTH" (number-to-string (length data))
-    "SCGI" "1")))
-
-(defun url-scgi-create-request ()
-  (concat (url-scgi-make-request-header url-request-data)
-          url-request-data))
-
-(defun url-scgi-activate-callback ()
-  "Activate callback specified when this buffer was created."
-  (apply url-callback-function url-callback-arguments))
-
-(defun url-scgi-handle-home-dir (filename)
-  (expand-file-name
-   (if (string-match "^/~" filename)
-       (substring filename 1)
-     filename)))
-
-;;;###autoload
-(defun url-scgi (url callback cbargs)
-  "Handle SCGI URLs from internal Emacs functions.
-
-URL must be a parsed URL.  See `url-generic-parse-url' for details.
-
-When retrieval is completed, execute the function CALLBACK, passing it
-an updated value of CBARGS as arguments."
-  (if (>= emacs-major-version 26)
-      (cl-check-type url url "Need a pre-parsed URL.")
-    (cl-check-type url vector "Need a pre-parsed URL."))
-  (declare (special url-scgi-connection-opened
-                    url-callback-function
-                    url-callback-arguments
-                    url-current-object))
-
-  (let* ((host (url-host url))
-         (port (url-port url))
-         (filename (url-filename url))
-         (is-local-socket (string-match "^/." filename))
-         (bufname (format " *scgi %s*" (if is-local-socket
-                                           filename
-                                         (format "%s:%d" host port))))
-         (buffer (generate-new-buffer bufname))
-         (connection (cond
-                      (is-local-socket
-                       (let ((filename (url-scgi-handle-home-dir filename)))
-                         (make-network-process :name "scgi"
-                                               :buffer buffer
-                                               :remote filename)))
-                      (t ; scgi over tcp
-                       (url-open-stream host buffer host port)))))
-    (if (not connection)
-        ;; Failed to open the connection for some reason
-        (progn
-          (kill-buffer buffer)
-          (setq buffer nil)
-          (error "Could not create connection to %s:%d" host port))
-      (with-current-buffer buffer
-        (setq url-current-object url
-              mode-line-format "%b [%s]")
-
-        (dolist (var '(url-scgi-connection-opened
-                       url-callback-function
-                       url-callback-arguments))
-          (set (make-local-variable var) nil))
-
-        (setq url-callback-function callback
-              url-callback-arguments cbargs
-              url-scgi-connection-opened nil)
-
-        (pcase (process-status connection)
-          (`connect
-           ;; Asynchronous connection
-           (set-process-sentinel connection 'url-scgi-async-sentinel))
-          (`failed
-           ;; Asynchronous connection failed
-           (error "Could not create connection to %s:%d" host port))
-          (_
-           (set-process-sentinel connection 'url-scgi-sync-open-sentinel)
-           (process-send-string connection (url-scgi-create-request))))))
-    buffer))
-
-(defun url-scgi-sync-open-sentinel (proc _)
-  (when (buffer-name (process-buffer proc))
-    (with-current-buffer (process-buffer proc)
-      (url-scgi-activate-callback))))
-
-(defun url-scgi-async-sentinel (proc why)
-  ;; We are performing an asynchronous connection, and a status change
-  ;; has occurred.
-  (with-current-buffer (process-buffer proc)
-    (cond
-     (url-scgi-connection-opened
-      (url-scgi-activate-callback))
-     ((string= (substring why 0 4) "open")
-      (setq url-scgi-connection-opened t)
-      (process-send-string proc (url-scgi-create-request)))
-     (t
-      (setf (car url-callback-arguments)
-            (nconc (list :error (list 'error 'connection-failed why
-                                      :host (url-host url-current-object)
-                                      :service (url-port url-current-object)))
-                   (car url-callback-arguments)))
-      (url-scgi-activate-callback)))))
-
-(provide 'url-scgi)
-
-;;; url-scgi.el ends here

Reply via email to