Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
e87f912b
Commit
e87f912b
authored
Mar 21, 2019
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: don't realloc the request
parent
10e8fe55
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
33 deletions
+29
-33
src/transports/http.c
+29
-33
No files found.
src/transports/http.c
View file @
e87f912b
...
@@ -1017,6 +1017,8 @@ static int http_stream_read(
...
@@ -1017,6 +1017,8 @@ static int http_stream_read(
http_subtransport
*
t
=
OWNING_SUBTRANSPORT
(
s
);
http_subtransport
*
t
=
OWNING_SUBTRANSPORT
(
s
);
parser_context
ctx
;
parser_context
ctx
;
size_t
bytes_parsed
;
size_t
bytes_parsed
;
git_buf
request
=
GIT_BUF_INIT
;
int
error
=
0
;
replay
:
replay
:
*
bytes_read
=
0
;
*
bytes_read
=
0
;
...
@@ -1024,20 +1026,12 @@ replay:
...
@@ -1024,20 +1026,12 @@ replay:
assert
(
t
->
connected
);
assert
(
t
->
connected
);
if
(
!
s
->
sent_request
)
{
if
(
!
s
->
sent_request
)
{
git_buf
request
=
GIT_BUF_INIT
;
git_buf_clear
(
&
request
);
clear_parser_state
(
t
);
clear_parser_state
(
t
);
if
(
gen_request
(
&
request
,
s
,
0
)
<
0
)
if
((
error
=
gen_request
(
&
request
,
s
,
0
))
<
0
||
return
-
1
;
(
error
=
git_stream__write_full
(
t
->
server
.
stream
,
request
.
ptr
,
request
.
size
,
0
))
<
0
)
goto
done
;
if
(
git_stream__write_full
(
t
->
server
.
stream
,
request
.
ptr
,
request
.
size
,
0
)
<
0
)
{
git_buf_dispose
(
&
request
);
return
-
1
;
}
git_buf_dispose
(
&
request
);
s
->
sent_request
=
1
;
s
->
sent_request
=
1
;
}
}
...
@@ -1047,17 +1041,17 @@ replay:
...
@@ -1047,17 +1041,17 @@ replay:
assert
(
s
->
verb
==
post_verb
);
assert
(
s
->
verb
==
post_verb
);
/* Flush, if necessary */
/* Flush, if necessary */
if
(
s
->
chunk_buffer_len
>
0
&&
if
(
s
->
chunk_buffer_len
>
0
)
{
write_chunk
(
t
->
server
.
stream
,
if
((
error
=
write_chunk
(
t
->
server
.
stream
,
s
->
chunk_buffer
,
s
->
chunk_buffer_len
))
<
0
)
s
->
chunk_buffer
,
s
->
chunk_buffer_len
)
<
0
)
goto
done
;
return
-
1
;
s
->
chunk_buffer_len
=
0
;
s
->
chunk_buffer_len
=
0
;
}
/* Write the final chunk. */
/* Write the final chunk. */
if
(
git_stream__write_full
(
t
->
server
.
stream
,
if
(
(
error
=
git_stream__write_full
(
t
->
server
.
stream
,
"0
\r\n\r\n
"
,
5
,
0
)
<
0
)
"0
\r\n\r\n
"
,
5
,
0
)
)
<
0
)
return
-
1
;
goto
done
;
}
}
s
->
received_response
=
1
;
s
->
received_response
=
1
;
...
@@ -1065,7 +1059,6 @@ replay:
...
@@ -1065,7 +1059,6 @@ replay:
while
(
!*
bytes_read
&&
!
t
->
parse_finished
)
{
while
(
!*
bytes_read
&&
!
t
->
parse_finished
)
{
size_t
data_offset
;
size_t
data_offset
;
int
error
;
/*
/*
* Make the parse_buffer think it's as full of data as
* Make the parse_buffer think it's as full of data as
...
@@ -1075,16 +1068,15 @@ replay:
...
@@ -1075,16 +1068,15 @@ replay:
* data_offset is the actual data offset from which we
* data_offset is the actual data offset from which we
* should tell the parser to start reading.
* should tell the parser to start reading.
*/
*/
if
(
buf_size
>=
t
->
parse_buffer
.
len
)
{
if
(
buf_size
>=
t
->
parse_buffer
.
len
)
t
->
parse_buffer
.
offset
=
0
;
t
->
parse_buffer
.
offset
=
0
;
}
else
{
else
t
->
parse_buffer
.
offset
=
t
->
parse_buffer
.
len
-
buf_size
;
t
->
parse_buffer
.
offset
=
t
->
parse_buffer
.
len
-
buf_size
;
}
data_offset
=
t
->
parse_buffer
.
offset
;
data_offset
=
t
->
parse_buffer
.
offset
;
if
(
gitno_recv
(
&
t
->
parse_buffer
)
<
0
)
if
(
(
error
=
gitno_recv
(
&
t
->
parse_buffer
)
)
<
0
)
return
-
1
;
goto
done
;
/* This call to http_parser_execute will result in invocations of the
/* This call to http_parser_execute will result in invocations of the
* on_* family of callbacks. The most interesting of these is
* on_* family of callbacks. The most interesting of these is
...
@@ -1113,27 +1105,31 @@ replay:
...
@@ -1113,27 +1105,31 @@ replay:
s
->
sent_request
=
0
;
s
->
sent_request
=
0
;
if
((
error
=
http_connect
(
t
))
<
0
)
if
((
error
=
http_connect
(
t
))
<
0
)
return
error
;
goto
done
;
goto
replay
;
goto
replay
;
}
}
if
(
t
->
parse_error
==
PARSE_ERROR_EXT
)
{
if
(
t
->
parse_error
==
PARSE_ERROR_EXT
)
{
return
t
->
error
;
error
=
t
->
error
;
goto
done
;
}
else
if
(
t
->
parse_error
<
0
)
{
error
=
-
1
;
goto
done
;
}
}
if
(
t
->
parse_error
<
0
)
return
-
1
;
if
(
bytes_parsed
!=
t
->
parse_buffer
.
offset
-
data_offset
)
{
if
(
bytes_parsed
!=
t
->
parse_buffer
.
offset
-
data_offset
)
{
git_error_set
(
GIT_ERROR_NET
,
git_error_set
(
GIT_ERROR_NET
,
"HTTP parser error: %s"
,
"HTTP parser error: %s"
,
http_errno_description
((
enum
http_errno
)
t
->
parser
.
http_errno
));
http_errno_description
((
enum
http_errno
)
t
->
parser
.
http_errno
));
return
-
1
;
error
=
-
1
;
goto
done
;
}
}
}
}
return
0
;
done
:
git_buf_dispose
(
&
request
);
return
error
;
}
}
static
int
http_stream_write_chunked
(
static
int
http_stream_write_chunked
(
...
...
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