url-vars.el 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. ;;; url-vars.el --- Variables for Uniform Resource Locator tool
  2. ;; Copyright (C) 1996-1999, 2001, 2004-2012 Free Software Foundation, Inc.
  3. ;; Keywords: comm, data, processes, hypermedia
  4. ;; This file is part of GNU Emacs.
  5. ;; GNU Emacs is free software: you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; GNU Emacs is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Code:
  16. (require 'mm-util)
  17. (defconst url-version "Emacs"
  18. "Version number of URL package.")
  19. (defgroup url nil
  20. "Uniform Resource Locator tool."
  21. :version "22.1"
  22. :group 'comm)
  23. (defgroup url-file nil
  24. "URL storage."
  25. :prefix "url-"
  26. :group 'url)
  27. (defgroup url-cache nil
  28. "URL cache."
  29. :prefix "url-"
  30. :prefix "url-cache-"
  31. :group 'url)
  32. (defgroup url-mime nil
  33. "MIME options of URL."
  34. :prefix "url-"
  35. :group 'url)
  36. (defgroup url-hairy nil
  37. "Hairy options of URL."
  38. :prefix "url-"
  39. :group 'url)
  40. (defvar url-current-object nil
  41. "A parsed representation of the current URL.")
  42. (defvar url-current-mime-headers nil
  43. "A parsed representation of the MIME headers for the current URL.")
  44. (mapc 'make-variable-buffer-local
  45. '(
  46. url-current-object
  47. url-current-mime-headers
  48. ))
  49. (defcustom url-honor-refresh-requests t
  50. "Whether to do automatic page reloads.
  51. These are done at the request of the document author or the server via
  52. the `Refresh' header in an HTTP response. If nil, no refresh
  53. requests will be honored. If t, all refresh requests will be honored.
  54. If non-nil and not t, the user will be asked for each refresh request."
  55. :type '(choice (const :tag "off" nil)
  56. (const :tag "on" t)
  57. (const :tag "ask" 'ask))
  58. :group 'url-hairy)
  59. (defcustom url-automatic-caching nil
  60. "If non-nil, all documents will be automatically cached to the local disk."
  61. :type 'boolean
  62. :group 'url-cache)
  63. (defconst url-bug-address "bug-gnu-emacs@gnu.org"
  64. "Where to send bug reports.")
  65. (defcustom url-personal-mail-address nil
  66. "Your full email address.
  67. This is what is sent to HTTP servers as the FROM field in an HTTP
  68. request."
  69. :type '(choice (const :tag "Unspecified" nil) string)
  70. :group 'url)
  71. (defcustom url-directory-index-file "index.html"
  72. "The filename to look for when indexing a directory.
  73. If this file exists, and is readable, then it will be viewed instead of
  74. using `dired' to view the directory."
  75. :type 'string
  76. :group 'url-file)
  77. (defcustom url-privacy-level '(email)
  78. "How private you want your requests to be.
  79. HTTP has header fields for various information about the user, including
  80. operating system information, email addresses, the last page you visited, etc.
  81. This variable controls how much of this information is sent.
  82. This should a symbol or a list.
  83. Valid values if a symbol are:
  84. none -- send all information
  85. low -- don't send the last location
  86. high -- don't send the email address or last location
  87. paranoid -- don't send anything
  88. If a list, this should be a list of symbols of what NOT to send.
  89. Valid symbols are:
  90. email -- the email address
  91. os -- the operating system info
  92. lastloc -- the last location
  93. agent -- do not send the User-Agent string
  94. cookies -- never accept HTTP cookies
  95. Samples:
  96. (setq url-privacy-level 'high)
  97. (setq url-privacy-level '(email lastloc)) ;; equivalent to 'high
  98. (setq url-privacy-level '(os))
  99. ::NOTE::
  100. This variable controls several other variables and is _NOT_ automatically
  101. updated. Call the function `url-setup-privacy-info' after modifying this
  102. variable."
  103. :initialize 'custom-initialize-default
  104. :set (lambda (sym val) (set-default sym val) (url-setup-privacy-info))
  105. :type '(radio (const :tag "None (you believe in the basic goodness of humanity)"
  106. :value none)
  107. (const :tag "Low (do not reveal last location)"
  108. :value low)
  109. (const :tag "High (no email address or last location)"
  110. :value high)
  111. (const :tag "Paranoid (reveal nothing!)"
  112. :value paranoid)
  113. (checklist :tag "Custom"
  114. (const :tag "Email address" :value email)
  115. (const :tag "Operating system" :value os)
  116. (const :tag "Last location" :value lastloc)
  117. (const :tag "Browser identification" :value agent)
  118. (const :tag "No cookies" :value cookie)))
  119. :group 'url)
  120. (defvar url-inhibit-uncompression nil "Do not do decompression if non-nil.")
  121. (defcustom url-uncompressor-alist '((".z" . "x-gzip")
  122. (".gz" . "x-gzip")
  123. (".uue" . "x-uuencoded")
  124. (".hqx" . "x-hqx")
  125. (".Z" . "x-compress")
  126. (".bz2" . "x-bzip2"))
  127. "An alist of file extensions and appropriate content-transfer-encodings."
  128. :type '(repeat (cons :format "%v"
  129. (string :tag "Extension")
  130. (string :tag "Encoding")))
  131. :group 'url-mime)
  132. (defcustom url-mail-command 'compose-mail
  133. "This function will be called whenever URL needs to send mail.
  134. It should enter a mail-mode-like buffer in the current window.
  135. The commands `mail-to' and `mail-subject' should still work in this
  136. buffer, and it should use `mail-header-separator' if possible."
  137. :type 'function
  138. :group 'url)
  139. (defcustom url-proxy-services nil
  140. "An alist of schemes and proxy servers that gateway them.
  141. Looks like ((\"http\" . \"hostname:portnumber\") ...). This is set up
  142. from the ACCESS_proxy environment variables."
  143. :type '(repeat (cons :format "%v"
  144. (string :tag "Protocol")
  145. (string :tag "Proxy")))
  146. :group 'url)
  147. (defcustom url-standalone-mode nil
  148. "Rely solely on the cache?"
  149. :type 'boolean
  150. :group 'url-cache)
  151. (defvar url-mime-separator-chars (mapcar 'identity
  152. (concat "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  153. "abcdefghijklmnopqrstuvwxyz"
  154. "0123456789'()+_,-./=?"))
  155. "Characters allowable in a MIME multipart separator.")
  156. (defcustom url-bad-port-list
  157. '("25" "119" "19")
  158. "List of ports to warn the user about connecting to.
  159. Defaults to just the mail, chargen, and NNTP ports so you cannot be
  160. tricked into sending fake mail or forging messages by a malicious HTML
  161. document."
  162. :type '(repeat (string :tag "Port"))
  163. :group 'url-hairy)
  164. (defvar url-mime-content-type-charset-regexp
  165. ";[ \t]*charset=\"?\\([^\"]+\\)\"?"
  166. "Regexp used in parsing `Content-Type' for a charset indication.")
  167. (defvar url-request-data nil "Any data to send with the next request.")
  168. (defvar url-request-extra-headers nil
  169. "A list of extra headers to send with the next request.
  170. Should be an assoc list of headers/contents.")
  171. (defvar url-request-method nil "The method to use for the next request.")
  172. ;; FIXME!! (RFC 2616 gives examples like `compress, gzip'.)
  173. (defvar url-mime-encoding-string nil
  174. "*String to send in the Accept-encoding: field in HTTP requests.")
  175. ;; Perhaps the first few should actually be given decreasing `q's and
  176. ;; the list should be trimmed significantly.
  177. ;; Fixme: do something sane if we don't have `sort-coding-systems'
  178. ;; (Emacs 20, XEmacs).
  179. (defun url-mime-charset-string ()
  180. "Generate a list of preferred MIME charsets for HTTP requests.
  181. Generated according to current coding system priorities."
  182. (if (fboundp 'sort-coding-systems)
  183. (let ((ordered (sort-coding-systems
  184. (let (accum)
  185. (dolist (elt mm-mime-mule-charset-alist)
  186. (if (mm-coding-system-p (car elt))
  187. (push (car elt) accum)))
  188. (nreverse accum)))))
  189. (concat (format "%s;q=1, " (pop ordered))
  190. (mapconcat 'symbol-name ordered ";q=0.5, ")
  191. ";q=0.5"))))
  192. (defvar url-mime-charset-string nil
  193. "*String to send in the Accept-charset: field in HTTP requests.
  194. The MIME charset corresponding to the most preferred coding system is
  195. given priority 1 and the rest are given priority 0.5.")
  196. (defun url-set-mime-charset-string ()
  197. (setq url-mime-charset-string (url-mime-charset-string)))
  198. ;; Regenerate if the language environment changes.
  199. (add-hook 'set-language-environment-hook 'url-set-mime-charset-string)
  200. ;; Fixme: set from the locale.
  201. (defcustom url-mime-language-string nil
  202. "String to send in the Accept-language: field in HTTP requests.
  203. Specifies the preferred language when servers can serve documents in
  204. several languages. Use RFC 1766 abbreviations, e.g.: `en' for
  205. English, `de' for German. A comma-separated specifies descending
  206. order of preference. The ordering can be made explicit using `q'
  207. factors defined by HTTP, e.g. `de,en-gb;q=0.8,en;q=0.7'. `*' means
  208. get the first available language (as opposed to the default)."
  209. :type '(radio
  210. (const :tag "None (get default language version)" :value nil)
  211. (const :tag "Any (get first available language version)" :value "*")
  212. (string :tag "Other"))
  213. :group 'url-mime
  214. :group 'i18n)
  215. (defvar url-mime-accept-string nil
  216. "String to send to the server in the Accept: field in HTTP requests.")
  217. (defvar url-package-version nil
  218. "Version number of package using URL.")
  219. (defvar url-package-name nil "Name of package using URL.")
  220. (defvar url-system-type nil
  221. "What type of system we are on.")
  222. (defvar url-os-type nil
  223. "What OS we are on.")
  224. (defcustom url-max-password-attempts 5
  225. "Maximum number of times a password will be prompted for.
  226. Applies when a protected document is denied by the server."
  227. :type 'integer
  228. :group 'url)
  229. (defcustom url-temporary-directory (or (getenv "TMPDIR") "/tmp")
  230. "Where temporary files go."
  231. :type 'directory
  232. :group 'url-file)
  233. (make-obsolete-variable 'url-temporary-directory
  234. 'temporary-file-directory "23.1")
  235. (defcustom url-show-status t
  236. "Whether to show a running total of bytes transferred.
  237. Can cause a large hit if using a remote X display over a slow link, or
  238. a terminal with a slow modem."
  239. :type 'boolean
  240. :group 'url)
  241. (defvar url-using-proxy nil
  242. "Either nil or the fully qualified proxy URL in use, e.g.
  243. http://www.example.com/")
  244. (defcustom url-news-server nil
  245. "The default news server from which to get newsgroups/articles.
  246. Applies if no server is specified in the URL. Defaults to the
  247. environment variable NNTPSERVER or \"news\" if NNTPSERVER is
  248. undefined."
  249. :type '(choice (const :tag "None" :value nil) string)
  250. :group 'url)
  251. (defvar url-nonrelative-link
  252. "\\`\\([-a-zA-Z0-9+.]+:\\)"
  253. "A regular expression that will match an absolute URL.")
  254. (defcustom url-max-redirections 30
  255. "The maximum number of redirection requests to honor in a HTTP connection.
  256. A negative number means to honor an unlimited number of redirection requests."
  257. :type 'integer
  258. :group 'url)
  259. (defcustom url-confirmation-func 'y-or-n-p
  260. "What function to use for asking yes or no functions.
  261. Possible values are `yes-or-no-p' or `y-or-n-p', or any function that
  262. takes a single argument (the prompt), and returns t only if a positive
  263. answer is given."
  264. :type '(choice (const :tag "Short (y or n)" :value y-or-n-p)
  265. (const :tag "Long (yes or no)" :value yes-or-no-p)
  266. (function :tag "Other"))
  267. :group 'url-hairy)
  268. (defcustom url-gateway-method 'native
  269. "The type of gateway support to use.
  270. Should be a symbol specifying how to get a connection from the local machine.
  271. Currently supported methods:
  272. `telnet': Run telnet in a subprocess to connect;
  273. `rlogin': Rlogin to another machine to connect;
  274. `socks': Connect through a socks server;
  275. `tls': Connect with TLS;
  276. `ssl': Connect with SSL (deprecated, use `tls' instead);
  277. `native': Connect directly."
  278. :type '(radio (const :tag "Telnet to gateway host" :value telnet)
  279. (const :tag "Rlogin to gateway host" :value rlogin)
  280. (const :tag "Use SOCKS proxy" :value socks)
  281. (const :tag "Use SSL/TLS for all connections" :value tls)
  282. (const :tag "Use SSL for all connections (obsolete)" :value ssl)
  283. (const :tag "Direct connection" :value native))
  284. :group 'url-hairy)
  285. (defvar url-setup-done nil "Has setup configuration been done?")
  286. (defconst url-weekday-alist
  287. '(("Sunday" . 0) ("Monday" . 1) ("Tuesday" . 2) ("Wednesday" . 3)
  288. ("Thursday" . 4) ("Friday" . 5) ("Saturday" . 6)
  289. ("Tues" . 2) ("Thurs" . 4)
  290. ("Sun" . 0) ("Mon" . 1) ("Tue" . 2) ("Wed" . 3)
  291. ("Thu" . 4) ("Fri" . 5) ("Sat" . 6)))
  292. (defconst url-monthabbrev-alist
  293. '(("Jan" . 1) ("Feb" . 2) ("Mar" . 3) ("Apr" . 4) ("May" . 5) ("Jun" . 6)
  294. ("Jul" . 7) ("Aug" . 8) ("Sep" . 9) ("Oct" . 10) ("Nov" . 11)
  295. ("Dec" . 12)))
  296. (defvar url-lazy-message-time 0)
  297. ;; Fixme: We may not be able to run SSL.
  298. (defvar url-extensions-header "Security/Digest Security/SSL")
  299. (defvar url-parse-syntax-table
  300. (copy-syntax-table emacs-lisp-mode-syntax-table)
  301. "*A syntax table for parsing URLs.")
  302. (modify-syntax-entry ?' "\"" url-parse-syntax-table)
  303. (modify-syntax-entry ?` "\"" url-parse-syntax-table)
  304. (modify-syntax-entry ?< "(>" url-parse-syntax-table)
  305. (modify-syntax-entry ?> ")<" url-parse-syntax-table)
  306. (modify-syntax-entry ?/ " " url-parse-syntax-table)
  307. (defvar url-load-hook nil
  308. "*Hooks to be run after initializing the URL library.")
  309. ;;; Make OS/2 happy - yeeks
  310. ;; (defvar tcp-binary-process-input-services nil
  311. ;; "*Make OS/2 happy with our CRLF pairs...")
  312. (defconst url-working-buffer " *url-work")
  313. (defvar url-gateway-unplugged nil
  314. "Non-nil means don't open new network connections.
  315. This should be set, e.g. by mail user agents rendering HTML to avoid
  316. `bugs' which call home.")
  317. (provide 'url-vars)
  318. ;;; url-vars.el ends here