Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d994cfc

Browse files
committed
http: propagate the credentials callback's error code
When we ask for credentials, the user may choose to return EUSER to indicate that an error has happened on its end and it wants to be given back control. We must therefore pass that back to the user instead of mentioning that it was on_headers_complete() that returned an error code. Since we can, we return the exact error code from the user (other than PASSTHROUGH) since it doesn't cost anything, though using other error codes aren't recommended.
1 parent 5470fd6 commit d994cfc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/transports/http.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ static const char *post_verb = "POST";
3636

3737
#define PARSE_ERROR_GENERIC -1
3838
#define PARSE_ERROR_REPLAY -2
39+
/** Look at the user field */
40+
#define PARSE_ERROR_EXT -3
3941

4042
#define CHUNK_SIZE 4096
4143

@@ -78,6 +80,7 @@ typedef struct {
7880
git_vector www_authenticate;
7981
enum last_cb last_cb;
8082
int parse_error;
83+
int error;
8184
unsigned parse_finished : 1;
8285

8386
/* Authentication */
@@ -351,7 +354,8 @@ static int on_headers_complete(http_parser *parser)
351354
if (error == GIT_PASSTHROUGH) {
352355
no_callback = 1;
353356
} else if (error < 0) {
354-
return PARSE_ERROR_GENERIC;
357+
t->error = error;
358+
return t->parse_error = PARSE_ERROR_EXT;
355359
} else {
356360
assert(t->cred);
357361

@@ -712,6 +716,10 @@ static int http_stream_read(
712716
goto replay;
713717
}
714718

719+
if (t->parse_error == PARSE_ERROR_EXT) {
720+
return t->error;
721+
}
722+
715723
if (t->parse_error < 0)
716724
return -1;
717725

0 commit comments

Comments
 (0)