Skip to content

Commit

Permalink
Check http response content
Browse files Browse the repository at this point in the history
  • Loading branch information
sepfy committed Aug 18, 2024
1 parent 496b669 commit f0c639b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/peer_signaling.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,22 @@ static int peer_signaling_http_post(const char *hostname, const char *path, int
res = peer_signaling_http_request(&trans_if, "POST", 4, hostname, strlen(hostname), path,
strlen(path), auth, strlen(auth), body, strlen(body));

ssl_transport_disconnect(&net_ctx);

if (res.pHeaders == NULL) {
LOGE("Response headers are NULL");
return -1;
}

if (res.pBody == NULL) {
LOGE("Response body is NULL");
return -1;
}

LOGI("Received HTTP response from %s%s\n"
"Response Headers: %s\nResponse Status: %u\nResponse Body: %s\n",
hostname, path, res.pHeaders, res.statusCode, res.pBody);

ssl_transport_disconnect(&net_ctx);

if (res.statusCode == 201) {
peer_connection_set_remote_description(g_ps.pc, (const char*)res.pBody);
}
Expand Down

0 comments on commit f0c639b

Please sign in to comment.