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
6644f4ac
Commit
6644f4ac
authored
Apr 10, 2023
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eget: real get_filename implementation
parent
7314c270
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
5 deletions
+59
-5
tools_eget
bin/tools_eget
+59
-5
No files found.
bin/tools_eget
View file @
6644f4ac
...
...
@@ -710,10 +710,37 @@ url_check()
__wget
--spider
-S
"
$URL
"
2>&1 |
grep
"HTTP/"
|
tail
-n1
|
grep
-q
"200"
}
url_get_headers
()
{
local
URL
=
"
$1
"
__wget
--spider
-S
"
$URL
"
2>&1 |
grep
"^ [A-Z].*: "
|
sed
-e
's|^ ||'
}
url_get_header
()
{
local
URL
=
"
$1
"
local
HEADER
=
"
$2
"
url_get_headers
"
$URL
"
|
grep
"^
$HEADER
: "
|
sed
-e
"s|^
$HEADER
: ||"
}
url_get_filename
()
{
# FIXME
basename
"
$1
"
local
URL
=
"
$1
"
# 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
local
loc
=
"
$(
url_get_header
"
$URL
"
"Location"
|
tail
-n1
)
"
if
is_url
"
$loc
"
;
then
basename
"
$loc
"
return
fi
basename
"
$URL
"
}
else
...
...
@@ -755,10 +782,38 @@ url_check()
__curl
-LI
"
$URL
"
2>&1 |
grep
"HTTP/"
|
tail
-n1
|
grep
-q
-w
"200
\|
404"
}
url_get_headers
()
{
local
URL
=
"
$1
"
__curl
-LI
"
$URL
"
2>&1 |
grep
"^[a-z].*: "
|
sed
-e
's|\r$||'
}
# TODO: the same code in wget case, but there other header names
url_get_header
()
{
local
URL
=
"
$1
"
local
HEADER
=
"
$2
"
url_get_headers
"
$URL
"
|
grep
"^
$HEADER
: "
|
sed
-e
"s|^
$HEADER
: ||"
}
url_get_filename
()
{
# FIXME
basename
"
$1
"
local
URL
=
"
$1
"
# 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
local
loc
=
"
$(
url_get_header
"
$URL
"
"location"
|
tail
-n1
)
"
if
is_url
"
$loc
"
;
then
basename
"
$loc
"
return
fi
basename
"
$URL
"
}
...
...
@@ -938,7 +993,6 @@ get_urls()
}
if
[
-n
"
$CHECKURL
"
]
;
then
#set_quiet
check_url_is_accessible
"
$1
"
...
...
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