Kaynağa Gözat

[http] Send authentication information whenever username is present

Send authentication information if the username is present, even if
the password is empty.
tags/v0.9.7
Michael Brown 15 yıl önce
ebeveyn
işleme
54840039f6
1 değiştirilmiş dosya ile 8 ekleme ve 9 silme
  1. 8
    9
      src/net/tcp/http.c

+ 8
- 9
src/net/tcp/http.c Dosyayı Görüntüle

@@ -391,10 +391,10 @@ static void http_step ( struct process *process ) {
391 391
 	const char *host = http->uri->host;
392 392
 	const char *query = http->uri->query;
393 393
 	const char *user = http->uri->user;
394
-	const char *password = http->uri->password;
395
-	size_t user_pw_len = ( ( user && password ) ?
396
-			       ( strlen ( user ) + 1 /* ":" */ +
397
-				 strlen ( password ) ) : 0 );
394
+	const char *password =
395
+		( http->uri->password ? http->uri->password : "" );
396
+	size_t user_pw_len = ( user ? ( strlen ( user ) + 1 /* ":" */ +
397
+					strlen ( password ) ) : 0 );
398 398
 	size_t user_pw_base64_len = base64_encoded_len ( user_pw_len );
399 399
 	char user_pw[ user_pw_len + 1 /* NUL */ ];
400 400
 	char user_pw_base64[ user_pw_base64_len + 1 /* NUL */ ];
@@ -406,7 +406,7 @@ static void http_step ( struct process *process ) {
406 406
 		process_del ( &http->process );
407 407
 
408 408
 		/* Construct authorisation, if applicable */
409
-		if ( user_pw_len ) {
409
+		if ( user ) {
410 410
 			char *buf = user_pw;
411 411
 			ssize_t remaining = sizeof ( user_pw );
412 412
 			size_t len;
@@ -435,11 +435,10 @@ static void http_step ( struct process *process ) {
435 435
 					  ( path ? path : "/" ),
436 436
 					  ( query ? "?" : "" ),
437 437
 					  ( query ? query : "" ),
438
-					  ( user_pw_len ?
438
+					  ( user ?
439 439
 					    "Authorization: Basic " : "" ),
440
-					  ( user_pw_len ?
441
-					    user_pw_base64 : "" ),
442
-					  ( user_pw_len ? "\r\n" : "" ),
440
+					  ( user ? user_pw_base64 : "" ),
441
+					  ( user ? "\r\n" : "" ),
443 442
 					  host ) ) != 0 ) {
444 443
 			http_done ( http, rc );
445 444
 		}

Loading…
İptal
Kaydet