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