Mercurial > pidgin
comparison libpurple/proxy.c @ 28671:f2a69bee9ef6
Don't send Proxy-Authorization headers until we've received a
`407 Proxy Authentication Required` response from the server. Fixes #2910,
which has an additional component about using existing kerberos tickets that
should be moved to a new trac ticket.
committer: John Bailey <rekkanoryo@rekkanoryo.org>
| author | thecrux@gmail.com |
|---|---|
| date | Sun, 29 Nov 2009 16:14:36 +0000 |
| parents | 30497d814cb9 |
| children | 0aa6080a6379 c01d4a1c7ee5 |
comparison
equal
deleted
inserted
replaced
| 28670:39a48c780bcb | 28671:f2a69bee9ef6 |
|---|---|
| 1096 request = g_string_sized_new(4096); | 1096 request = g_string_sized_new(4096); |
| 1097 g_string_append_printf(request, | 1097 g_string_append_printf(request, |
| 1098 "CONNECT %s:%d HTTP/1.1\r\nHost: %s:%d\r\n", | 1098 "CONNECT %s:%d HTTP/1.1\r\nHost: %s:%d\r\n", |
| 1099 connect_data->host, connect_data->port, | 1099 connect_data->host, connect_data->port, |
| 1100 connect_data->host, connect_data->port); | 1100 connect_data->host, connect_data->port); |
| 1101 | |
| 1102 if (purple_proxy_info_get_username(connect_data->gpi) != NULL) | |
| 1103 { | |
| 1104 char *t1, *t2, *ntlm_type1; | |
| 1105 char hostname[256]; | |
| 1106 | |
| 1107 ret = gethostname(hostname, sizeof(hostname)); | |
| 1108 hostname[sizeof(hostname) - 1] = '\0'; | |
| 1109 if (ret < 0 || hostname[0] == '\0') { | |
| 1110 purple_debug_warning("proxy", "gethostname() failed -- is your hostname set?"); | |
| 1111 strcpy(hostname, "localhost"); | |
| 1112 } | |
| 1113 | |
| 1114 t1 = g_strdup_printf("%s:%s", | |
| 1115 purple_proxy_info_get_username(connect_data->gpi), | |
| 1116 purple_proxy_info_get_password(connect_data->gpi) ? | |
| 1117 purple_proxy_info_get_password(connect_data->gpi) : ""); | |
| 1118 t2 = purple_base64_encode((const guchar *)t1, strlen(t1)); | |
| 1119 g_free(t1); | |
| 1120 | |
| 1121 ntlm_type1 = purple_ntlm_gen_type1(hostname, ""); | |
| 1122 | |
| 1123 g_string_append_printf(request, | |
| 1124 "Proxy-Authorization: Basic %s\r\n" | |
| 1125 "Proxy-Authorization: NTLM %s\r\n" | |
| 1126 "Proxy-Connection: Keep-Alive\r\n", | |
| 1127 t2, ntlm_type1); | |
| 1128 g_free(ntlm_type1); | |
| 1129 g_free(t2); | |
| 1130 } | |
| 1131 | 1101 |
| 1132 g_string_append(request, "\r\n"); | 1102 g_string_append(request, "\r\n"); |
| 1133 | 1103 |
| 1134 connect_data->write_buf_len = request->len; | 1104 connect_data->write_buf_len = request->len; |
| 1135 connect_data->write_buffer = (guchar *)g_string_free(request, FALSE); | 1105 connect_data->write_buffer = (guchar *)g_string_free(request, FALSE); |
