Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
4b36f74b
Commit
4b36f74b
authored
Aug 01, 2018
by
Francisco Javier López 🌴 On vacation; back on August 22th!
Committed by
Nick Thomas
Aug 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug setting http headers in Files API
parent
dae5c266
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
1 deletion
+40
-1
changelogs/unreleased/fj-49802-bug-api-set-http-headers.yml
changelogs/unreleased/fj-49802-bug-api-set-http-headers.yml
+5
-0
lib/api/helpers/headers_helpers.rb
lib/api/helpers/headers_helpers.rb
+5
-1
spec/requests/api/files_spec.rb
spec/requests/api/files_spec.rb
+30
-0
No files found.
changelogs/unreleased/fj-49802-bug-api-set-http-headers.yml
0 → 100644
View file @
4b36f74b
---
title
:
Fix bug setting http headers in Files API
merge_request
:
20938
author
:
type
:
fixed
lib/api/helpers/headers_helpers.rb
View file @
4b36f74b
...
...
@@ -3,7 +3,11 @@ module API
module
HeadersHelpers
def
set_http_headers
(
header_data
)
header_data
.
each
do
|
key
,
value
|
header
"X-Gitlab-
#{
key
.
to_s
.
split
(
'_'
).
collect
(
&
:capitalize
).
join
(
'-'
)
}
"
,
value
if
value
.
is_a?
(
Enumerable
)
raise
ArgumentError
.
new
(
"Header value should be a string"
)
end
header
"X-Gitlab-
#{
key
.
to_s
.
split
(
'_'
).
collect
(
&
:capitalize
).
join
(
'-'
)
}
"
,
value
.
to_s
end
end
end
...
...
spec/requests/api/files_spec.rb
View file @
4b36f74b
...
...
@@ -13,6 +13,24 @@ describe API::Files do
let
(
:author_email
)
{
'user@example.org'
}
let
(
:author_name
)
{
'John Doe'
}
let
(
:helper
)
do
fake_class
=
Class
.
new
do
include
::
API
::
Helpers
::
HeadersHelpers
attr_reader
:headers
def
initialize
@headers
=
{}
end
def
header
(
key
,
value
)
@headers
[
key
]
=
value
end
end
fake_class
.
new
end
before
do
project
.
add_developer
(
user
)
end
...
...
@@ -21,6 +39,18 @@ describe API::Files do
"/projects/
#{
project
.
id
}
/repository/files/
#{
file_path
}
"
end
context
'http headers'
do
it
'converts value into string'
do
helper
.
set_http_headers
(
test:
1
)
expect
(
helper
.
headers
).
to
eq
({
'X-Gitlab-Test'
=>
'1'
})
end
it
'raises exception if value is an Enumerable'
do
expect
{
helper
.
set_http_headers
(
test:
[
1
])
}.
to
raise_error
(
ArgumentError
)
end
end
describe
"HEAD /projects/:id/repository/files/:file_path"
do
shared_examples_for
'repository files'
do
it
'returns file attributes in headers'
do
...
...
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