Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
04c23739
Commit
04c23739
authored
Jun 22, 2010
by
Mark A. Hershberger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add in some useful convenience functions for handling HTTP.
parent
bc869eca
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
0 deletions
+73
-0
lisp/gnus/ChangeLog
lisp/gnus/ChangeLog
+5
-0
lisp/gnus/mm-url.el
lisp/gnus/mm-url.el
+42
-0
lisp/url/ChangeLog
lisp/url/ChangeLog
+6
-0
lisp/url/url-parse.el
lisp/url/url-parse.el
+20
-0
No files found.
lisp/gnus/ChangeLog
View file @
04c23739
2010-06-22 Mark A. Hershberger <mah@everybody.org>
* mm-url.el (mm-url-encode-multipart-form-data): New function to handle
the *other* type of HTML form submission.
2010-06-15 Michael Albinus <michael.albinus@gmx.de>
2010-06-15 Michael Albinus <michael.albinus@gmx.de>
* auth-source.el (auth-source-pick): If choice does not contain a
* auth-source.el (auth-source-pick): If choice does not contain a
...
...
lisp/gnus/mm-url.el
View file @
04c23739
...
@@ -418,6 +418,48 @@ spaces. Die Die Die."
...
@@ -418,6 +418,48 @@ spaces. Die Die Die."
(
mm-url-form-encode-xwfu
(
cdr
data
))))
(
mm-url-form-encode-xwfu
(
cdr
data
))))
pairs
"&"
))
pairs
"&"
))
(
defun
mm-url-encode-multipart-form-data
(
pairs
&optional
boundary
)
"Return PAIRS encoded in multipart/form-data."
;; RFC1867
;; Get a good boundary
(
unless
boundary
(
setq
boundary
(
mml-compute-boundary
'
())))
(
concat
;; Start with the boundary
"--"
boundary
"\r\n"
;; Create name value pairs
(
mapconcat
'identity
;; Delete any returned items that are empty
(
delq
nil
(
mapcar
(
lambda
(
data
)
(
when
(
car
data
)
;; For each pair
(
concat
;; Encode the name
"Content-Disposition: form-data; name=\""
(
car
data
)
"\"\r\n"
"Content-Type: text/plain; charset=utf-8\r\n"
"Content-Transfer-Encoding: binary\r\n\r\n"
(
cond
((
stringp
(
cdr
data
))
(
cdr
data
))
((
integerp
(
cdr
data
))
(
int-to-string
(
cdr
data
))))
"\r\n"
)))
pairs
))
;; use the boundary as a separator
(
concat
"--"
boundary
"\r\n"
))
;; put a boundary at the end.
"--"
boundary
"--\r\n"
))
(
defun
mm-url-fetch-form
(
url
pairs
)
(
defun
mm-url-fetch-form
(
url
pairs
)
"Fetch a form from URL with PAIRS as the data using the POST method."
"Fetch a form from URL with PAIRS as the data using the POST method."
(
mm-url-load-url
)
(
mm-url-load-url
)
...
...
lisp/url/ChangeLog
View file @
04c23739
2010-06-22 Mark A. Hershberger <mah@everybody.org>
* url-parse.el (url-user-for-url, url-password-for-url):
Convenience functions that get usernames and passwords for urls
from auth-source functions.
2010-06-12 Štěpán Němec <stepnem@gmail.com> (tiny change)
2010-06-12 Štěpán Němec <stepnem@gmail.com> (tiny change)
* url-vars.el (url-privacy-level): Fix doc typo. (Bug#6406)
* url-vars.el (url-privacy-level): Fix doc typo. (Bug#6406)
...
...
lisp/url/url-parse.el
View file @
04c23739
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
;;; Code:
;;; Code:
(
require
'url-vars
)
(
require
'url-vars
)
(
require
'auth-source
)
(
eval-when-compile
(
require
'cl
))
(
eval-when-compile
(
require
'cl
))
(
autoload
'url-scheme-get-property
"url-methods"
)
(
autoload
'url-scheme-get-property
"url-methods"
)
...
@@ -174,6 +175,25 @@ TYPE USER PASSWORD HOST PORTSPEC FILENAME TARGET ATTRIBUTES FULLNESS."
...
@@ -174,6 +175,25 @@ TYPE USER PASSWORD HOST PORTSPEC FILENAME TARGET ATTRIBUTES FULLNESS."
(
url-parse-make-urlobj
(
url-parse-make-urlobj
prot
user
pass
host
port
file
refs
attr
full
)))))))
prot
user
pass
host
port
file
refs
attr
full
)))))))
(
defmacro
url-bit-for-url
(
method
lookfor
url
)
`
(
let*
((
urlobj
(
url-generic-parse-url
url
))
(
bit
(
funcall
,
method
urlobj
))
(
methods
(
list
'url-recreate-url
'url-host
)))
(
while
(
and
(
not
bit
)
(
>
(
length
methods
)
0
))
(
setq
bit
(
auth-source-user-or-password
,
lookfor
(
funcall
(
pop
methods
)
urlobj
)
(
url-type
urlobj
))))
bit
))
(
defun
url-user-for-url
(
url
)
"Attempt to use .authinfo to find a user for this URL."
(
url-bit-for-url
'url-user
"login"
url
))
(
defun
url-password-for-url
(
url
)
"Attempt to use .authinfo to find a password for this URL."
(
url-bit-for-url
'url-password
"password"
url
))
(
provide
'url-parse
)
(
provide
'url-parse
)
;; arch-tag: f338325f-71ab-4bee-93cc-78fb9a03d403
;; arch-tag: f338325f-71ab-4bee-93cc-78fb9a03d403
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment