Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osug-doi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSUG
Pôle Numérique
osug-doi
Commits
bed9a4dd
Commit
bed9a4dd
authored
4 years ago
by
bourgesl
Browse files
Options
Downloads
Patches
Plain Diff
fixed url checker if HTTP HEAD method is unsupported by web server
parent
e62fa236
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/fr/osug/doi/service/UrlChecker.java
+15
-10
15 additions, 10 deletions
src/main/java/fr/osug/doi/service/UrlChecker.java
with
15 additions
and
10 deletions
src/main/java/fr/osug/doi/service/UrlChecker.java
+
15
−
10
View file @
bed9a4dd
...
...
@@ -45,13 +45,13 @@ public class UrlChecker {
public
String
getResource
(
final
String
url
,
final
boolean
headOnly
)
{
// Note: url must not be encoded (%)
if
(
url
.
contains
(
"%"
))
{
logger
.
info
(
"Url is encoded (may cause problem with HTTP request) : {}"
,
url
);
logger
.
info
(
"getResource: url is encoded (may cause problem with HTTP request) : {}"
,
url
);
}
else
{
logger
.
debug
(
"getResource: {}"
,
url
);
}
String
response
=
null
;
try
{
logger
.
debug
(
"getResource: {}"
,
url
);
if
(
headOnly
)
{
if
(
headOnly
)
{
try
{
final
HttpHeaders
headers
=
this
.
restTemplate
.
headForHeaders
(
url
);
if
(
headers
!=
null
)
{
...
...
@@ -60,14 +60,19 @@ public class UrlChecker {
}
response
=
headers
.
getContentType
().
toString
();
}
}
else
{
}
catch
(
RestClientException
rce
)
{
logger
.
warn
(
"getResource({}): failed: {}"
,
url
,
rce
.
getMessage
());
}
}
// if not headOnly or head failed:
if
(
response
==
null
)
{
try
{
response
=
this
.
restTemplate
.
getForObject
(
url
,
String
.
class
);
}
catch
(
RestClientException
rce
)
{
logger
.
warn
(
"getResource({}): failed: {}"
,
url
,
rce
.
getMessage
());
}
}
catch
(
RestClientException
rce
)
{
logger
.
error
(
"getResource: failed"
,
rce
);
}
logger
.
debug
(
"getResource:\n{}"
,
response
);
logger
.
debug
(
"getResource
({})
:\n{}"
,
url
,
response
);
return
response
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment