Skip to content

Commit

Permalink
Read status as long and cast to int before heading into the database
Browse files Browse the repository at this point in the history
  • Loading branch information
pramsey committed Nov 21, 2017
1 parent 8024a43 commit cf664b8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,8 @@ Datum http_request(PG_FUNCTION_ARGS)
StringInfoData si_read;

int http_return;
long status;
long long_status;
int status;
char *content_type = NULL;
int content_charset = -1;

Expand Down Expand Up @@ -968,7 +969,7 @@ Datum http_request(PG_FUNCTION_ARGS)
}

/* Read the metadata from the handle directly */
if ( (CURLE_OK != curl_easy_getinfo(g_http_handle, CURLINFO_RESPONSE_CODE, &status)) ||
if ( (CURLE_OK != curl_easy_getinfo(g_http_handle, CURLINFO_RESPONSE_CODE, &long_status)) ||
(CURLE_OK != curl_easy_getinfo(g_http_handle, CURLINFO_CONTENT_TYPE, &content_type)) )
{
curl_slist_free_all(headers);
Expand All @@ -984,7 +985,8 @@ Datum http_request(PG_FUNCTION_ARGS)
nulls = palloc0(sizeof(bool)*ncolumns);

/* Status code */
values[RESP_STATUS] = Int64GetDatum(status);
status = long_status;
values[RESP_STATUS] = Int32GetDatum(status);
nulls[RESP_STATUS] = false;

/* Content type */
Expand Down

0 comments on commit cf664b8

Please sign in to comment.