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
29762e40
Commit
29762e40
authored
Jan 01, 2020
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
httpclient: use defines for status codes
parent
3e9ee04f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
14 deletions
+25
-14
src/transports/http.c
+5
-4
src/transports/httpclient.c
+10
-10
src/transports/httpclient.h
+10
-0
No files found.
src/transports/http.c
View file @
29762e40
...
...
@@ -243,22 +243,23 @@ static int handle_response(
/* If we're in the middle of challenge/response auth, continue. */
if
(
allow_replay
&&
response
->
resend_credentials
)
{
return
0
;
}
else
if
(
allow_replay
&&
response
->
status
==
401
)
{
}
else
if
(
allow_replay
&&
response
->
status
==
GIT_HTTP_STATUS_UNAUTHORIZED
)
{
if
((
error
=
handle_remote_auth
(
stream
,
response
))
<
0
)
return
error
;
return
git_http_client_skip_body
(
transport
->
http_client
);
}
else
if
(
allow_replay
&&
response
->
status
==
407
)
{
}
else
if
(
allow_replay
&&
response
->
status
==
GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED
)
{
if
((
error
=
handle_proxy_auth
(
stream
,
response
))
<
0
)
return
error
;
return
git_http_client_skip_body
(
transport
->
http_client
);
}
else
if
(
response
->
status
==
401
||
response
->
status
==
407
)
{
}
else
if
(
response
->
status
==
GIT_HTTP_STATUS_UNAUTHORIZED
||
response
->
status
==
GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED
)
{
git_error_set
(
GIT_ERROR_NET
,
"unexpected authentication failure"
);
return
-
1
;
}
if
(
response
->
status
!=
200
)
{
if
(
response
->
status
!=
GIT_HTTP_STATUS_OK
)
{
git_error_set
(
GIT_ERROR_NET
,
"unexpected http status code: %d"
,
response
->
status
);
return
-
1
;
}
...
...
src/transports/httpclient.c
View file @
29762e40
...
...
@@ -126,11 +126,11 @@ struct git_http_client {
bool
git_http_response_is_redirect
(
git_http_response
*
response
)
{
return
(
response
->
status
==
301
||
response
->
status
==
302
||
response
->
status
==
303
||
response
->
status
==
307
||
response
->
status
==
308
);
return
(
response
->
status
==
GIT_HTTP_MOVED_PERMANENTLY
||
response
->
status
==
GIT_HTTP_FOUND
||
response
->
status
==
GIT_HTTP_SEE_OTHER
||
response
->
status
==
GIT_HTTP_TEMPORARY_REDIRECT
||
response
->
status
==
GIT_HTTP_PERMANENT_REDIRECT
);
}
void
git_http_response_dispose
(
git_http_response
*
response
)
...
...
@@ -316,13 +316,13 @@ static int resend_needed(git_http_client *client, git_http_response *response)
{
git_http_auth_context
*
auth_context
;
if
(
response
->
status
==
401
&&
if
(
response
->
status
==
GIT_HTTP_STATUS_UNAUTHORIZED
&&
(
auth_context
=
client
->
server
.
auth_context
)
&&
auth_context
->
is_complete
&&
!
auth_context
->
is_complete
(
auth_context
))
return
1
;
if
(
response
->
status
==
407
&&
if
(
response
->
status
==
GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED
&&
(
auth_context
=
client
->
proxy
.
auth_context
)
&&
auth_context
->
is_complete
&&
!
auth_context
->
is_complete
(
auth_context
))
...
...
@@ -914,12 +914,12 @@ static int proxy_connect(
assert
(
client
->
state
==
DONE
);
if
(
response
.
status
==
407
)
{
if
(
response
.
status
==
GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED
)
{
save_early_response
(
client
,
&
response
);
error
=
GIT_RETRY
;
goto
done
;
}
else
if
(
response
.
status
!=
200
)
{
}
else
if
(
response
.
status
!=
GIT_HTTP_STATUS_OK
)
{
git_error_set
(
GIT_ERROR_NET
,
"proxy returned unexpected status: %d"
,
response
.
status
);
error
=
-
1
;
goto
done
;
...
...
@@ -1236,7 +1236,7 @@ int git_http_client_send_request(
error
=
0
;
if
(
response
.
status
!=
100
)
{
if
(
response
.
status
!=
GIT_HTTP_STATUS_CONTINUE
)
{
save_early_response
(
client
,
&
response
);
goto
done
;
}
...
...
src/transports/httpclient.h
View file @
29762e40
...
...
@@ -11,6 +11,16 @@
#include "common.h"
#include "net.h"
#define GIT_HTTP_STATUS_CONTINUE 100
#define GIT_HTTP_STATUS_OK 200
#define GIT_HTTP_MOVED_PERMANENTLY 301
#define GIT_HTTP_FOUND 302
#define GIT_HTTP_SEE_OTHER 303
#define GIT_HTTP_TEMPORARY_REDIRECT 307
#define GIT_HTTP_PERMANENT_REDIRECT 308
#define GIT_HTTP_STATUS_UNAUTHORIZED 401
#define GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED 407
typedef
struct
git_http_client
git_http_client
;
/** Method for the HTTP request */
...
...
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