1 ;;; url-vars.el --- Variables for Uniform Resource Locator tool
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Keywords: comm, data, processes, hypermedia
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
29 (defconst url-version "Emacs"
30 "Version number of URL package.")
33 "Uniform Resource Locator tool."
37 (defgroup url-file nil
42 (defgroup url-cache nil
48 (defgroup url-mime nil
49 "MIME options of URL."
53 (defgroup url-hairy nil
54 "Hairy options of URL."
59 (defvar url-current-object nil
60 "A parsed representation of the current url.")
62 (defvar url-current-mime-headers nil
63 "A parsed representation of the MIME headers for the current url.")
65 (mapcar 'make-variable-buffer-local
69 url-current-mime-headers
72 (defcustom url-honor-refresh-requests t
73 "*Whether to do automatic page reloads.
74 These are done at the request of the document author or the server via
75 the `Refresh' header in an HTTP response. If nil, no refresh
76 requests will be honored. If t, all refresh requests will be honored.
77 If non-nil and not t, the user will be asked for each refresh
79 :type '(choice (const :tag "off" nil)
81 (const :tag "ask" 'ask))
84 (defcustom url-automatic-caching nil
85 "*If non-nil, all documents will be automatically cached to the local disk."
89 ;; Fixme: sanitize this.
90 (defcustom url-cache-expired
91 (lambda (t1 t2) (>= (- (car t2) (car t1)) 5))
92 "*A function determining if a cached item has expired.
93 It takes two times (numbers) as its arguments, and returns non-nil if
94 the second time is 'too old' when compared to the first time."
98 (defconst url-bug-address "bug-gnu-emacs@gnu.org"
99 "Where to send bug reports.")
101 (defcustom url-personal-mail-address nil
102 "*Your full email address.
103 This is what is sent to HTTP servers as the FROM field in an HTTP
105 :type '(choice (const :tag "Unspecified" nil) string)
108 (defcustom url-directory-index-file "index.html"
109 "*The filename to look for when indexing a directory.
110 If this file exists, and is readable, then it will be viewed instead of
111 using `dired' to view the directory."
115 ;; Fixme: this should have a setter which calls url-setup-privacy-info.
116 (defcustom url-privacy-level '(email)
117 "*How private you want your requests to be.
118 HTTP has header fields for various information about the user, including
119 operating system information, email addresses, the last page you visited, etc.
120 This variable controls how much of this information is sent.
122 This should a symbol or a list.
123 Valid values if a symbol are:
124 none -- Send all information
125 low -- Don't send the last location
126 high -- Don't send the email address or last location
127 paranoid -- Don't send anything
129 If a list, this should be a list of symbols of what NOT to send.
131 email -- the email address
132 os -- the operating system info
133 lastloc -- the last location
134 agent -- Do not send the User-Agent string
135 cookie -- never accept HTTP cookies
139 (setq url-privacy-level 'high)
140 (setq url-privacy-level '(email lastloc)) ;; equivalent to 'high
141 (setq url-privacy-level '(os))
144 This variable controls several other variables and is _NOT_ automatically
145 updated. Call the function `url-setup-privacy-info' after modifying this
147 :type '(radio (const :tag "None (you believe in the basic goodness of humanity)"
149 (const :tag "Low (do not reveal last location)"
151 (const :tag "High (no email address or last location)"
153 (const :tag "Paranoid (reveal nothing!)"
155 (checklist :tag "Custom"
156 (const :tag "Email address" :value email)
157 (const :tag "Operating system" :value os)
158 (const :tag "Last location" :value lastloc)
159 (const :tag "Browser identification" :value agent)
160 (const :tag "No cookies" :value cookie)))
163 (defvar url-inhibit-uncompression nil "Do not do decompression if non-nil.")
165 (defcustom url-uncompressor-alist '((".z" . "x-gzip")
167 (".uue" . "x-uuencoded")
169 (".Z" . "x-compress")
170 (".bz2" . "x-bzip2"))
171 "*An alist of file extensions and appropriate content-transfer-encodings."
172 :type '(repeat (cons :format "%v"
173 (string :tag "Extension")
174 (string :tag "Encoding")))
177 (defcustom url-mail-command (if (fboundp 'compose-mail)
180 "*This function will be called whenever url needs to send mail.
181 It should enter a mail-mode-like buffer in the current window.
182 The commands `mail-to' and `mail-subject' should still work in this
183 buffer, and it should use `mail-header-separator' if possible."
187 (defcustom url-proxy-services nil
188 "*An alist of schemes and proxy servers that gateway them.
189 Looks like ((\"http\" . \"hostname:portnumber\") ...). This is set up
190 from the ACCESS_proxy environment variables."
191 :type '(repeat (cons :format "%v"
192 (string :tag "Protocol")
193 (string :tag "Proxy")))
196 (defcustom url-standalone-mode nil
197 "*Rely solely on the cache?"
201 (defvar url-mime-separator-chars (mapcar 'identity
202 (concat "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
203 "abcdefghijklmnopqrstuvwxyz"
204 "0123456789'()+_,-./=?"))
205 "Characters allowable in a MIME multipart separator.")
207 (defcustom url-bad-port-list
209 "*List of ports to warn the user about connecting to.
210 Defaults to just the mail, chargen, and NNTP ports so you cannot be
211 tricked into sending fake mail or forging messages by a malicious HTML
213 :type '(repeat (string :tag "Port"))
216 (defvar url-mime-content-type-charset-regexp
217 ";[ \t]*charset=\"?\\([^\"]+\\)\"?"
218 "Regexp used in parsing `Content-Type' for a charset indication.")
220 (defvar url-request-data nil "Any data to send with the next request.")
222 (defvar url-request-extra-headers nil
223 "A list of extra headers to send with the next request.
224 Should be an assoc list of headers/contents.")
226 (defvar url-request-method nil "The method to use for the next request.")
228 ;; FIXME!! (RFC 2616 gives examples like `compress, gzip'.)
229 (defvar url-mime-encoding-string nil
230 "*String to send in the Accept-encoding: field in HTTP requests.")
232 ;; Perhaps the first few should actually be given decreasing `q's and
233 ;; the list should be trimmed significantly.
234 ;; Fixme: do something sane if we don't have `sort-coding-systems'
235 ;; (Emacs 20, XEmacs).
236 (defun url-mime-charset-string ()
237 "Generate a list of preferred MIME charsets for HTTP requests.
238 Generated according to current coding system priorities."
239 (if (fboundp 'sort-coding-systems)
240 (let ((ordered (sort-coding-systems
242 (dolist (elt mm-mime-mule-charset-alist)
243 (if (mm-coding-system-p (car elt))
244 (push (car elt) accum)))
246 (concat (format "%s;q=1, " (pop ordered))
247 (mapconcat 'symbol-name ordered ";q=0.5, ")
250 (defvar url-mime-charset-string (url-mime-charset-string)
251 "*String to send in the Accept-charset: field in HTTP requests.
252 The MIME charset corresponding to the most preferred coding system is
253 given priority 1 and the rest are given priority 0.5.")
255 (defun url-set-mime-charset-string ()
256 (setq url-mime-charset-string (url-mime-charset-string)))
257 ;; Regenerate if the language environment changes.
258 (add-hook 'set-language-environment-hook 'url-set-mime-charset-string)
260 ;; Fixme: set from the locale.
261 (defcustom url-mime-language-string nil
262 "*String to send in the Accept-language: field in HTTP requests.
264 Specifies the preferred language when servers can serve documents in
265 several languages. Use RFC 1766 abbreviations, e.g.@: `en' for
266 English, `de' for German. A comma-separated specifies descending
267 order of preference. The ordering can be made explicit using `q'
268 factors defined by HTTP, e.g. `de,en-gb;q=0.8,en;q=0.7'. `*' means
269 get the first available language (as opposed to the default)."
271 (const :tag "None (get default language version)" :value nil)
272 (const :tag "Any (get first available language version)" :value "*")
273 (string :tag "Other"))
277 (defvar url-mime-accept-string nil
278 "String to send to the server in the Accept: field in HTTP requests.")
280 (defvar url-package-version nil
281 "Version number of package using URL.")
283 (defvar url-package-name nil "Version number of package using URL.")
285 (defvar url-system-type nil
286 "What type of system we are on.")
287 (defvar url-os-type nil
288 "What OS we are on.")
290 (defcustom url-max-password-attempts 5
291 "*Maximum number of times a password will be prompted for.
292 Applies when a protected document is denied by the server."
296 (defcustom url-temporary-directory (or (getenv "TMPDIR") "/tmp")
297 "*Where temporary files go."
301 (defcustom url-show-status t
302 "*Whether to show a running total of bytes transferred.
303 Can cause a large hit if using a remote X display over a slow link, or
304 a terminal with a slow modem."
308 (defvar url-using-proxy nil
309 "Either nil or the fully qualified proxy URL in use, e.g.
310 http://www.domain.com/")
312 (defcustom url-news-server nil
313 "*The default news server from which to get newsgroups/articles.
314 Applies if no server is specified in the URL. Defaults to the
315 environment variable NNTPSERVER or \"news\" if NNTPSERVER is
317 :type '(choice (const :tag "None" :value nil) string)
320 (defvar url-nonrelative-link
321 "\\`\\([-a-zA-Z0-9+.]+:\\)"
322 "A regular expression that will match an absolute URL.")
324 (defcustom url-confirmation-func 'y-or-n-p
325 "*What function to use for asking yes or no functions.
326 Possible values are `yes-or-no-p' or `y-or-n-p', or any function that
327 takes a single argument (the prompt), and returns t only if a positive
329 :type '(choice (const :tag "Short (y or n)" :value y-or-n-p)
330 (const :tag "Long (yes or no)" :value yes-or-no-p)
331 (function :tag "Other"))
334 (defcustom url-gateway-method 'native
335 "*The type of gateway support to use.
336 Should be a symbol specifying how to get a connection from the local machine.
338 Currently supported methods:
339 `telnet': Run telnet in a subprocess to connect;
340 `rlogin': Rlogin to another machine to connect;
341 `socks': Connect through a socks server;
342 `tls': Connect with TLS;
343 `ssl': Connect with SSL (deprecated, use `tls' instead);
344 `native': Connect directy."
345 :type '(radio (const :tag "Telnet to gateway host" :value telnet)
346 (const :tag "Rlogin to gateway host" :value rlogin)
347 (const :tag "Use SOCKS proxy" :value socks)
348 (const :tag "Use SSL/TLS for all connections" :value tls)
349 (const :tag "Use SSL for all connections (obsolete)" :value ssl)
350 (const :tag "Direct connection" :value native))
353 (defvar url-setup-done nil "Has setup configuration been done?")
355 (defconst url-weekday-alist
356 '(("Sunday" . 0) ("Monday" . 1) ("Tuesday" . 2) ("Wednesday" . 3)
357 ("Thursday" . 4) ("Friday" . 5) ("Saturday" . 6)
358 ("Tues" . 2) ("Thurs" . 4)
359 ("Sun" . 0) ("Mon" . 1) ("Tue" . 2) ("Wed" . 3)
360 ("Thu" . 4) ("Fri" . 5) ("Sat" . 6)))
362 (defconst url-monthabbrev-alist
363 '(("Jan" . 1) ("Feb" . 2) ("Mar" . 3) ("Apr" . 4) ("May" . 5) ("Jun" . 6)
364 ("Jul" . 7) ("Aug" . 8) ("Sep" . 9) ("Oct" . 10) ("Nov" . 11)
367 (defvar url-lazy-message-time 0)
369 ;; Fixme: We may not be able to run SSL.
370 (defvar url-extensions-header "Security/Digest Security/SSL")
372 (defvar url-parse-syntax-table
373 (copy-syntax-table emacs-lisp-mode-syntax-table)
374 "*A syntax table for parsing URLs.")
376 (modify-syntax-entry ?' "\"" url-parse-syntax-table)
377 (modify-syntax-entry ?` "\"" url-parse-syntax-table)
378 (modify-syntax-entry ?< "(>" url-parse-syntax-table)
379 (modify-syntax-entry ?> ")<" url-parse-syntax-table)
380 (modify-syntax-entry ?/ " " url-parse-syntax-table)
382 (defvar url-load-hook nil
383 "*Hooks to be run after initalizing the URL library.")
385 ;;; Make OS/2 happy - yeeks
386 ;; (defvar tcp-binary-process-input-services nil
387 ;; "*Make OS/2 happy with our CRLF pairs...")
389 (defconst url-working-buffer " *url-work")
391 (defvar url-gateway-unplugged nil
392 "Non-nil means don't open new network connections.
393 This should be set, e.g. by mail user agents rendering HTML to avoid
394 `bugs' which call home.")
396 (defun url-vars-unload-hook ()
397 (remove-hook 'set-language-environment-hook 'url-set-mime-charset-string))
399 (add-hook 'url-vars-unload-hook 'url-vars-unload-hook)
403 ;;; arch-tag: 29205e5f-c5ce-433c-8d5d-38cbaed64b49
404 ;;; url-vars.el ends here