Skip to content

Commit

Permalink
Correctly handle HTTP redirects after POST request
Browse files Browse the repository at this point in the history
  • Loading branch information
EionRobb committed Aug 17, 2024
1 parent aeb36b5 commit 569bdcb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion purple2compat/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,7 @@ static gboolean _purple_http_recv_loopbody(PurpleHttpConnection *hc, gint fd)
hc->request->max_redirects > hc->redirects_count))
{
PurpleHttpURL *url = purple_http_url_parse(redirect);
PurpleHttpRequest *req = hc->request;

hc->redirects_count++;

Expand All @@ -1290,6 +1291,9 @@ static gboolean _purple_http_recv_loopbody(PurpleHttpConnection *hc, gint fd)
purple_http_url_relative(hc->url, url);
purple_http_url_free(url);

purple_http_request_set_method(req, "GET");
purple_http_request_set_contents(req, NULL, 0);

_purple_http_reconnect(hc);
return FALSE;
}
Expand Down Expand Up @@ -2639,7 +2643,7 @@ void purple_http_request_set_contents(PurpleHttpRequest *request,
return;
}

if (length == 0)
if (length == -1)
length = strlen(contents);
request->contents = g_memdup2(contents, length);
request->contents_length = length;
Expand Down

0 comments on commit 569bdcb

Please sign in to comment.