Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Federation Library
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ganggo
Federation Library
Commits
d3cb1bd4
Commit
d3cb1bd4
authored
Nov 23, 2017
by
zauberstuhl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fallback to http if FetchJson fails with ssl
parent
2b8153b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
http_client.go
http_client.go
+8
-1
No files found.
http_client.go
View file @
d3cb1bd4
...
@@ -69,7 +69,11 @@ func push(host, endpoint, proto, contentType string, body io.Reader) error {
...
@@ -69,7 +69,11 @@ func push(host, endpoint, proto, contentType string, body io.Reader) error {
}
}
func
FetchJson
(
method
,
url
string
,
body
io
.
Reader
,
result
interface
{})
error
{
func
FetchJson
(
method
,
url
string
,
body
io
.
Reader
,
result
interface
{})
error
{
req
,
err
:=
http
.
NewRequest
(
method
,
url
,
body
)
var
proto
string
if
!
strings
.
HasPrefix
(
url
,
"http"
)
{
proto
=
"https://"
}
req
,
err
:=
http
.
NewRequest
(
method
,
proto
+
url
,
body
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -80,6 +84,9 @@ func FetchJson(method, url string, body io.Reader, result interface{}) error {
...
@@ -80,6 +84,9 @@ func FetchJson(method, url string, body io.Reader, result interface{}) error {
}
}
resp
,
err
:=
client
.
Do
(
req
)
resp
,
err
:=
client
.
Do
(
req
)
if
err
!=
nil
{
if
err
!=
nil
{
if
!
strings
.
HasPrefix
(
url
,
"http"
)
{
return
FetchJson
(
method
,
"http://"
+
url
,
body
,
result
)
}
return
err
return
err
}
}
...
...
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