Mercurial > pidgin
comparison src/protocols/msn/httpmethod.c @ 8207:aa44049e8891
[gaim-migrate @ 8930]
This doesn't fix HTTP method, but it does add debug info and prevent
sending PNGs when using HTTP method, since that would cause a disconnect.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Wed, 04 Feb 2004 06:26:54 +0000 |
| parents | 99ffabc6ce73 |
| children | f24172f53650 |
comparison
equal
deleted
inserted
replaced
| 8206:e0d16895a0e3 | 8207:aa44049e8891 |
|---|---|
| 48 static gboolean | 48 static gboolean |
| 49 http_poll(gpointer data) | 49 http_poll(gpointer data) |
| 50 { | 50 { |
| 51 MsnServConn *servconn = data; | 51 MsnServConn *servconn = data; |
| 52 | 52 |
| 53 #if 0 | |
| 54 gaim_debug_info("msn", "Polling server %s.\n", | 53 gaim_debug_info("msn", "Polling server %s.\n", |
| 55 servconn->http_data->gateway_ip); | 54 servconn->http_data->gateway_ip); |
| 56 #endif | |
| 57 msn_http_servconn_poll(servconn); | 55 msn_http_servconn_poll(servconn); |
| 58 | 56 |
| 59 servconn->http_data->timer = 0; | 57 servconn->http_data->timer = 0; |
| 58 | |
| 59 gaim_debug(GAIM_DEBUG_INFO, "msn", "Returning from http_poll\n"); | |
| 60 | 60 |
| 61 return FALSE; | 61 return FALSE; |
| 62 } | 62 } |
| 63 | 63 |
| 64 static void | 64 static void |
| 65 stop_timer(MsnServConn *servconn) | 65 stop_timer(MsnServConn *servconn) |
| 66 { | 66 { |
| 67 if (servconn->http_data->timer) | 67 if (servconn->http_data->timer) |
| 68 { | 68 { |
| 69 gaim_debug(GAIM_DEBUG_INFO, "msn", "Stopping timer\n"); | |
| 69 g_source_remove(servconn->http_data->timer); | 70 g_source_remove(servconn->http_data->timer); |
| 70 servconn->http_data->timer = 0; | 71 servconn->http_data->timer = 0; |
| 71 } | 72 } |
| 72 } | 73 } |
| 73 | 74 |
| 74 static void | 75 static void |
| 75 start_timer(MsnServConn *servconn) | 76 start_timer(MsnServConn *servconn) |
| 76 { | 77 { |
| 77 stop_timer(servconn); | 78 stop_timer(servconn); |
| 78 | 79 |
| 80 gaim_debug(GAIM_DEBUG_INFO, "msn", "Starting timer\n"); | |
| 79 servconn->http_data->timer = g_timeout_add(5000, http_poll, servconn); | 81 servconn->http_data->timer = g_timeout_add(5000, http_poll, servconn); |
| 80 } | 82 } |
| 81 | 83 |
| 82 size_t | 84 size_t |
| 83 msn_http_servconn_write(MsnServConn *servconn, const char *buf, size_t size, | 85 msn_http_servconn_write(MsnServConn *servconn, const char *buf, size_t size, |
| 160 servconn->fd, temp); | 162 servconn->fd, temp); |
| 161 #endif | 163 #endif |
| 162 | 164 |
| 163 s = 0; | 165 s = 0; |
| 164 needed = strlen(temp); | 166 needed = strlen(temp); |
| 165 | 167 |
| 166 do { | 168 do { |
| 167 res = write(servconn->fd, temp, needed); | 169 res = write(servconn->fd, temp, needed); |
| 168 if (res >= 0) | 170 if (res >= 0) |
| 169 s += res; | 171 s += res; |
| 170 else if (errno != EAGAIN) { | 172 else if (errno != EAGAIN) { |
| 172 gaim_connection_error(servconn->session->account->gc, msg); | 174 gaim_connection_error(servconn->session->account->gc, msg); |
| 173 g_free(msg); | 175 g_free(msg); |
| 174 return -1; | 176 return -1; |
| 175 } | 177 } |
| 176 } while (s < needed); | 178 } while (s < needed); |
| 177 | 179 |
| 178 g_free(temp); | 180 g_free(temp); |
| 179 | 181 |
| 180 servconn->http_data->waiting_response = TRUE; | 182 servconn->http_data->waiting_response = TRUE; |
| 181 | 183 |
| 182 servconn->http_data->virgin = FALSE; | 184 servconn->http_data->virgin = FALSE; |
| 215 "\r\n", | 217 "\r\n", |
| 216 servconn->http_data->gateway_ip, | 218 servconn->http_data->gateway_ip, |
| 217 servconn->http_data->session_id, | 219 servconn->http_data->session_id, |
| 218 servconn->http_data->gateway_ip); | 220 servconn->http_data->gateway_ip); |
| 219 | 221 |
| 220 #if 0 | |
| 221 gaim_debug_misc("msn", "Writing to HTTP: {%s}\n", temp); | 222 gaim_debug_misc("msn", "Writing to HTTP: {%s}\n", temp); |
| 222 #endif | |
| 223 | 223 |
| 224 s = write(servconn->fd, temp, strlen(temp)); | 224 s = write(servconn->fd, temp, strlen(temp)); |
| 225 | 225 |
| 226 g_free(temp); | 226 g_free(temp); |
| 227 | 227 |
| 250 g_return_val_if_fail(size > 0, FALSE); | 250 g_return_val_if_fail(size > 0, FALSE); |
| 251 g_return_val_if_fail(ret_buf != NULL, FALSE); | 251 g_return_val_if_fail(ret_buf != NULL, FALSE); |
| 252 g_return_val_if_fail(ret_size != NULL, FALSE); | 252 g_return_val_if_fail(ret_size != NULL, FALSE); |
| 253 g_return_val_if_fail(error != NULL, FALSE); | 253 g_return_val_if_fail(error != NULL, FALSE); |
| 254 | 254 |
| 255 #if 0 | |
| 256 gaim_debug_info("msn", "parsing data {%s} from fd %d\n", buf, servconn->fd); | 255 gaim_debug_info("msn", "parsing data {%s} from fd %d\n", buf, servconn->fd); |
| 257 #endif | |
| 258 servconn->http_data->waiting_response = FALSE; | 256 servconn->http_data->waiting_response = FALSE; |
| 259 | 257 |
| 260 gc = gaim_account_get_connection(servconn->session->account); | 258 gc = gaim_account_get_connection(servconn->session->account); |
| 261 | 259 |
| 262 /* Healthy defaults. */ | 260 /* Healthy defaults. */ |
| 298 | 296 |
| 299 headers = g_strndup(buf, s - buf); | 297 headers = g_strndup(buf, s - buf); |
| 300 s += 4; /* Skip \r\n */ | 298 s += 4; /* Skip \r\n */ |
| 301 body = g_strndup(s, size - (s - buf)); | 299 body = g_strndup(s, size - (s - buf)); |
| 302 | 300 |
| 303 #if 0 | |
| 304 gaim_debug_misc("msn", "Incoming HTTP buffer: {%s\r\n%s}", headers, body); | 301 gaim_debug_misc("msn", "Incoming HTTP buffer: {%s\r\n%s}", headers, body); |
| 305 #endif | |
| 306 | 302 |
| 307 if ((s = strstr(headers, "Content-Length: ")) != NULL) | 303 if ((s = strstr(headers, "Content-Length: ")) != NULL) |
| 308 { | 304 { |
| 309 s += strlen("Content-Length: "); | 305 s += strlen("Content-Length: "); |
| 310 | 306 |
