comparison libpurple/protocols/yahoo/yahoo_filexfer.c @ 26909:fac90dbe196d

Various minor cleanups. The majority of this is the #define for the useragent. Also notable: Tighter scoping for variables and fewer magic numbers in the parsing of the server response.
author Paul Aurich <paul@darkrain42.org>
date Wed, 13 May 2009 18:40:41 +0000
parents 4bac03b3c0fd
children 510f07e1f5c1 c2ac87c5a035
comparison
equal deleted inserted replaced
26908:ade63a6ca986 26909:fac90dbe196d
1247 if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND && xd->status_15 == ACCEPTED) 1247 if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND && xd->status_15 == ACCEPTED)
1248 { 1248 {
1249 if(xd->info_val_249 == 2) 1249 if(xd->info_val_249 == 2)
1250 { 1250 {
1251 /* sending file via p2p, we are connected as client */ 1251 /* sending file via p2p, we are connected as client */
1252 xd->txbuf = g_strdup_printf("POST /%s HTTP/1.1\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\nHost: %s\r\nContent-Length: %ld\r\nCache-Control: no-cache\r\n\r\n", 1252 xd->txbuf = g_strdup_printf("POST /%s HTTP/1.1\r\n"
1253 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
1254 "Host: %s\r\n"
1255 "Content-Length: %ld\r\n"
1256 "Cache-Control: no-cache\r\n\r\n",
1253 xd->path, 1257 xd->path,
1254 xd->host, 1258 xd->host,
1255 (long int)xfer->size); /* to do, add Referer */ 1259 (long int)xfer->size); /* to do, add Referer */
1256 } 1260 }
1257 else 1261 else
1258 { 1262 {
1259 /* sending file via relaying */ 1263 /* sending file via relaying */
1260 xd->txbuf = g_strdup_printf("POST /relay?token=%s&sender=%s&recver=%s HTTP/1.1\r\nCookie:%s\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\nHost: %s\r\nContent-Length: %ld\r\nCache-Control: no-cache\r\n\r\n", 1264 xd->txbuf = g_strdup_printf("POST /relay?token=%s&sender=%s&recver=%s HTTP/1.1\r\n"
1265 "Cookie:%s\r\n"
1266 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
1267 "Host: %s\r\n"
1268 "Content-Length: %ld\r\n"
1269 "Cache-Control: no-cache\r\n\r\n",
1261 purple_url_encode(xd->xfer_idstring_for_relay), 1270 purple_url_encode(xd->xfer_idstring_for_relay),
1262 purple_normalize(account, purple_account_get_username(account)), 1271 purple_normalize(account, purple_account_get_username(account)),
1263 xfer->who, 1272 xfer->who,
1264 cookies, 1273 cookies,
1265 xd->host, 1274 xd->host,
1269 else if(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE && xd->status_15 == STARTED) 1278 else if(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE && xd->status_15 == STARTED)
1270 { 1279 {
1271 if(xd->info_val_249 == 1) 1280 if(xd->info_val_249 == 1)
1272 { 1281 {
1273 /* receiving file via p2p, connected as client */ 1282 /* receiving file via p2p, connected as client */
1274 xd->txbuf = g_strdup_printf("HEAD /%s HTTP/1.1\r\nAccept:*/*\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\nHost: %s\r\nContent-Length: 0\r\nCache-Control: no-cache\r\n\r\n",xd->path,xd->host); 1283 xd->txbuf = g_strdup_printf("HEAD /%s HTTP/1.1\r\n"
1284 "Accept: */*\r\n"
1285 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
1286 "Host: %s\r\n"
1287 "Content-Length: 0\r\n"
1288 "Cache-Control: no-cache\r\n\r\n",
1289 xd->path,xd->host);
1275 } 1290 }
1276 else 1291 else
1277 { 1292 {
1278 /* receiving file via relaying */ 1293 /* receiving file via relaying */
1279 xd->txbuf = g_strdup_printf("HEAD /relay?token=%s&sender=%s&recver=%s HTTP/1.1\r\nAccept:*/*\r\nCookie:%s\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\nHost:%s\r\nContent-Length: 0\r\nCache-Control: no-cache\r\n\r\n", 1294 xd->txbuf = g_strdup_printf("HEAD /relay?token=%s&sender=%s&recver=%s HTTP/1.1\r\n"
1295 "Accept: */*\r\n"
1296 "Cookie: %s\r\n"
1297 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
1298 "Host: %s\r\n"
1299 "Content-Length: 0\r\n"
1300 "Cache-Control: no-cache\r\n\r\n",
1280 purple_url_encode(xd->xfer_idstring_for_relay), 1301 purple_url_encode(xd->xfer_idstring_for_relay),
1281 purple_normalize(account, purple_account_get_username(account)), 1302 purple_normalize(account, purple_account_get_username(account)),
1282 xfer->who, 1303 xfer->who,
1283 cookies, 1304 cookies,
1284 xd->host); 1305 xd->host);
1287 else if(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE && xd->status_15 == HEAD_REPLY_RECEIVED) 1308 else if(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE && xd->status_15 == HEAD_REPLY_RECEIVED)
1288 { 1309 {
1289 if(xd->info_val_249 == 1) 1310 if(xd->info_val_249 == 1)
1290 { 1311 {
1291 /* receiving file via p2p, connected as client */ 1312 /* receiving file via p2p, connected as client */
1292 xd->txbuf = g_strdup_printf("GET /%s HTTP/1.1\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\nHost: %s\r\nConnection: Keep-Alive\r\n\r\n",xd->path,xd->host); 1313 xd->txbuf = g_strdup_printf("GET /%s HTTP/1.1\r\n"
1314 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
1315 "Host: %s\r\n"
1316 "Connection: Keep-Alive\r\n\r\n",
1317 xd->path, xd->host);
1293 } 1318 }
1294 else 1319 else
1295 { 1320 {
1296 /* receiving file via relaying */ 1321 /* receiving file via relaying */
1297 xd->txbuf = g_strdup_printf("GET /relay?token=%s&sender=%s&recver=%s HTTP/1.1\r\nCookie:%s\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\nHost:%s\r\nConnection: Keep-Alive\r\n\r\n", 1322 xd->txbuf = g_strdup_printf("GET /relay?token=%s&sender=%s&recver=%s HTTP/1.1\r\n"
1323 "Cookie: %s\r\n"
1324 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
1325 "Host: %s\r\n"
1326 "Connection: Keep-Alive\r\n\r\n",
1298 purple_url_encode(xd->xfer_idstring_for_relay), 1327 purple_url_encode(xd->xfer_idstring_for_relay),
1299 purple_normalize(account, purple_account_get_username(account)), 1328 purple_normalize(account, purple_account_get_username(account)),
1300 xfer->who, 1329 xfer->who,
1301 cookies, 1330 cookies,
1302 xd->host); 1331 xd->host);