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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
32fbe618
Commit
32fbe618
authored
Jan 26, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix HTTP::IO
parent
0e8a9c43
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
19 deletions
+26
-19
lib/gitlab/ci/trace.rb
lib/gitlab/ci/trace.rb
+2
-2
lib/gitlab/ci/trace/http_io.rb
lib/gitlab/ci/trace/http_io.rb
+24
-17
No files found.
lib/gitlab/ci/trace.rb
View file @
32fbe618
...
...
@@ -65,7 +65,7 @@ module Gitlab
def
read
stream
=
Gitlab
::
Ci
::
Trace
::
Stream
.
new
do
if
trace_artifact
&
.
exists?
if
trace_artifact
trace_artifact
.
open
elsif
current_path
File
.
open
(
current_path
,
"rb"
)
...
...
@@ -92,7 +92,7 @@ module Gitlab
end
def
erase!
trace_artifact
&
.
dest
or
y
trace_artifact
&
.
dest
ro
y
paths
.
each
do
|
trace_path
|
FileUtils
.
rm
(
trace_path
,
force:
true
)
...
...
lib/gitlab/ci/trace/http_io.rb
View file @
32fbe618
require
'net/http'
##
#
# This class is compatible with IO class (https://ruby-doc.org/core-2.3.1/IO.html)
# source: https://gitlab.com/snippets/1685610
module
Gitlab
module
Ci
class
Trace
class
HTTP_IO
BUFFER_SIZE
=
128
*
1024
BUFFER_SIZE
=
128
.
kilobytes
attr_reader
:uri
,
:size
attr_reader
:tell
attr_reader
:chunk
,
:chunk_range
alias_method
:pos
,
:tell
def
initialize
(
url
,
size
)
@uri
=
URI
(
url
)
@size
=
size
...
...
@@ -24,13 +23,14 @@ module Gitlab
end
def
binmode
# no-op
end
def
path
@uri
.
to_s
end
def
seek
(
pos
,
where
)
def
seek
(
pos
,
where
=
IO
::
SEEK_SET
)
new_pos
=
case
where
when
IO
::
SEEK_END
...
...
@@ -54,38 +54,43 @@ module Gitlab
def
each_line
while
!
eof?
do
line
=
read
_
line
line
=
readline
yield
(
line
)
end
end
def
read
def
read
(
length
=
nil
)
out
=
""
loop
do
while
length
.
nil?
||
out
.
length
<
length
data
=
get_chunk
break
if
data
.
empty?
out
+=
data
@tell
+=
data
.
bytesize
end
if
length
&&
out
.
length
>
length
extra
=
out
.
length
-
length
out
=
out
[
0
..-
extra
]
end
out
end
def
readline
out
=
""
data
=
get_chunk
while
!
data
.
empty?
do
new_line
=
data
.
index
(
'\n'
)
while
!
eof?
do
data
=
get_chunk
new_line
=
data
.
index
(
"
\n
"
)
if
!
new_line
.
nil?
out
=
data
[
0
..
new_line
]
out
+
=
data
[
0
..
new_line
]
@tell
+=
new_line
+
1
break
elsif
data
.
empty?
break
else
out
=
data
out
+
=
data
@tell
+=
data
.
bytesize
data
=
get_chunk
end
end
...
...
@@ -110,6 +115,9 @@ module Gitlab
private
##
# The below methods are not implemented in IO class
#
def
in_range?
@chunk_range
&
.
include?
(
tell
)
end
...
...
@@ -129,7 +137,6 @@ module Gitlab
def
request
Net
::
HTTP
::
Get
.
new
(
uri
).
tap
do
|
request
|
puts
"Requesting chunk:
#{
chunk_start
}
-
#{
chunk_end
}
"
request
.
set_range
(
chunk_start
,
BUFFER_SIZE
)
end
end
...
...
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