diff options
author | Sulabh Mahajan <sulabh@pidgin.im> | 2009-03-01 09:50:59 +0000 |
---|---|---|
committer | Sulabh Mahajan <sulabh@pidgin.im> | 2009-03-01 09:50:59 +0000 |
commit | ea687ee2a437d8cb09c1d528740d58c2a641a875 (patch) | |
tree | c78cdf34a709030230c448965480d618a055033b | |
parent | f72b9f15ba792834ba8194d789c0b9514ca51744 (diff) | |
download | pidgin-ea687ee2a437d8cb09c1d528740d58c2a641a875.tar.gz |
When acting as a p2p server, send HTTP OK after receiving file.
-rw-r--r-- | libpurple/protocols/yahoo/yahoo_filexfer.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libpurple/protocols/yahoo/yahoo_filexfer.c b/libpurple/protocols/yahoo/yahoo_filexfer.c index 4e1dbba46a..ebf1b69ec0 100644 --- a/libpurple/protocols/yahoo/yahoo_filexfer.c +++ b/libpurple/protocols/yahoo/yahoo_filexfer.c @@ -609,6 +609,26 @@ static void yahoo_xfer_cancel_recv(PurpleXfer *xfer) xfer->data = NULL; } +/* Send HTTP OK after receiving file */ +static void yahoo_p2p_ft_server_send_OK(PurpleXfer *xfer) +{ + char *tx = NULL; + int written; + + tx = g_strdup_printf("HTTP/1.1 200 OK\r\nContent-Length: 0\r\nContent-Type: application/octet-stream\r\nConnection: close\r\n\r\n"); + written = write(xfer->fd, tx, strlen(tx)); + + if (written < 0 && errno == EAGAIN) + written = 0; + else if (written <= 0) + purple_debug_info("yahoo", "p2p filetransfer: Unable to write HTTP OK"); + + /* close connection */ + close(xfer->fd); + xfer->fd = -1; + g_free(tx); +} + static void yahoo_xfer_end(PurpleXfer *xfer_old) { struct yahoo_xfer_data *xfer_data; @@ -620,6 +640,10 @@ static void yahoo_xfer_end(PurpleXfer *xfer_old) if(xfer_data && xfer_data->version == 15 && purple_xfer_get_type(xfer_old) == PURPLE_XFER_RECEIVE && xfer_data->filename_list) { + + /* Send HTTP OK in case of p2p transfer, when we act as server */ + if((xfer_data->xfer_url != NULL) && (xfer_old->fd >=0) && (purple_xfer_get_status(xfer_old) == PURPLE_XFER_STATUS_DONE)) + yahoo_p2p_ft_server_send_OK(xfer_old); /* removing top of filename & size list completely */ g_free( xfer_data->filename_list->data ); |