| 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 } |
| 1101 |
1131 |
| 1102 g_string_append(request, "\r\n"); |
1132 g_string_append(request, "\r\n"); |
| 1103 |
1133 |
| 1104 connect_data->write_buf_len = request->len; |
1134 connect_data->write_buf_len = request->len; |
| 1105 connect_data->write_buffer = (guchar *)g_string_free(request, FALSE); |
1135 connect_data->write_buffer = (guchar *)g_string_free(request, FALSE); |