Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eepm
Commits
63e8a85d
Commit
63e8a85d
authored
Apr 10, 2023
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eget: use common functions url_get_real_url and url_get_get_filename, fix it
parent
3f8bd5d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
50 deletions
+11
-50
tools_eget
bin/tools_eget
+11
-50
No files found.
bin/tools_eget
View file @
63e8a85d
...
...
@@ -839,52 +839,9 @@ url_check()
url_get_headers
()
{
local
URL
=
"
$1
"
__wget
--spider
-S
"
$URL
"
2>&1 |
grep
"^ [A-Z].*: "
|
sed
-e
's|^
||'
__wget
--spider
-S
"
$URL
"
2>&1 |
grep
-i
"^ *[[:alpha:]].*: "
|
sed
-e
's|^ *
||'
}
url_get_header
()
{
local
URL
=
"
$1
"
local
HEADER
=
"
$2
"
url_get_headers
"
$URL
"
|
grep
-i
"^
$HEADER
: "
|
sed
-e
"s|^
$HEADER
: ||i"
}
url_get_real_url
()
{
local
URL
=
"
$1
"
!
is_httpurl
"
$URL
"
&&
echo
"
$URL
"
&&
return
# don't check location if we have made form of the URL
[
-n
"
$MADEURL
"
]
&&
[
"
$MADEURL
"
=
"
$URL
"
]
&&
echo
"
$URL
"
&&
return
local
loc
for
loc
in
$(
url_get_header
"
$URL
"
"Location"
|
tac
)
;
do
if
!
is_strange_url
"
$loc
"
;
then
echo
"
$loc
"
return
fi
done
echo
"
$URL
"
}
url_get_filename
()
{
local
URL
=
"
$1
"
!
is_httpurl
"
$URL
"
&&
basename
"
$URL
"
&&
return
# FIXME with wget
local cd
=
"
$(
url_get_header
"
$URL
"
"Content-Disposition"
)
"
if
echo
"
$cd
"
|
grep
-q
"filename="
;
then
#Content-Disposition: attachment; filename=postman-linux-x64.tar.gz
echo
"
$cd
"
|
sed
-e
's|.*filename=||'
return
fi
basename
"
$(
url_get_real_url
"
$URL
"
)
"
}
elif
[
"
$EGET_BACKEND
"
=
"curl"
]
;
then
...
...
@@ -927,15 +884,20 @@ url_check()
url_get_headers
()
{
local
URL
=
"
$1
"
__curl
-LI
"
$URL
"
2>&1 |
grep
"^[a-z
].*: "
|
sed
-e
's|\r$||'
__curl
-LI
"
$URL
"
2>&1 |
grep
-i
"^ *[[:alpha:]
].*: "
|
sed
-e
's|\r$||'
}
# TODO: the same code in wget case, but there other header names
fi
# Common code for both wget and curl (http related)
if
[
"
$EGET_BACKEND
"
=
"wget"
]
||
[
"
$EGET_BACKEND
"
=
"curl"
]
;
then
url_get_header
()
{
local
URL
=
"
$1
"
local
HEADER
=
"
$2
"
url_get_headers
"
$URL
"
|
grep
"^
$HEADER
: "
|
sed
-e
"s|^
$HEADER
: ||
"
url_get_headers
"
$URL
"
|
grep
-i
"^ *
$HEADER
: "
|
sed
-e
"s|^ *
$HEADER
: ||i
"
}
url_get_real_url
()
...
...
@@ -948,7 +910,7 @@ url_get_real_url()
[
-n
"
$MADEURL
"
]
&&
[
"
$MADEURL
"
=
"
$URL
"
]
&&
echo
"
$URL
"
&&
return
local
loc
for
loc
in
$(
url_get_header
"
$URL
"
"
l
ocation"
|
tac
)
;
do
for
loc
in
$(
url_get_header
"
$URL
"
"
L
ocation"
|
tac
)
;
do
if
!
is_strange_url
"
$loc
"
;
then
echo
"
$loc
"
return
...
...
@@ -965,7 +927,7 @@ url_get_filename()
!
is_httpurl
"
$URL
"
&&
basename
"
$URL
"
&&
return
# FIXME with wget
local cd
=
"
$(
url_get_header
"
$URL
"
"
content-d
isposition"
)
"
local cd
=
"
$(
url_get_header
"
$URL
"
"
Content-D
isposition"
)
"
if
echo
"
$cd
"
|
grep
-q
"filename="
;
then
#Content-Disposition: attachment; filename=postman-linux-x64.tar.gz
echo
"
$cd
"
|
sed
-e
's|.*filename=||'
...
...
@@ -978,7 +940,6 @@ url_get_filename()
fi
if
[
"
$ipfs_mode
"
!=
"disabled"
]
&&
[
-n
"
$EGET_IPFS_DB
"
]
&&
!
is_ipfsurl
"
$1
"
;
then
download_to_ipfs
()
...
...
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