Skip to content

Commit 5d38e48

Browse files
committed
Add CurlGetErrorMessage to get a more detailed string error.
Fixed enum tool. Added new enums. Updated test script.
1 parent 219b012 commit 5d38e48

File tree

8 files changed

+996
-773
lines changed

8 files changed

+996
-773
lines changed

context.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CurlContext::CurlContext(CURL* c, IPluginContext* plugin) {
1010
handle_closed = false;
1111
headers = NULL;
1212
post = NULL;
13+
curl_error_message[0] = 0;
1314
}
1415

1516
CurlContext::~CurlContext() {

context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class CurlContext {
2727
int sourcepawn_userdata;
2828
bool in_event_thread;
2929
bool handle_closed; // if someone try to close the handle when it was processing, close it when it times out or completes
30+
char curl_error_message[CURL_ERROR_SIZE];
3031

3132
CurlContext(CURL* c, IPluginContext* plugin);
3233
~CurlContext();

extension.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ void ProcessCurlJob(CurlContext* c) {
212212
curl_easy_setopt(c->curl, CURLOPT_HEADERDATA, (void*)c);
213213
curl_easy_setopt(c->curl, CURLOPT_PRIVATE, (void*)c);
214214
curl_easy_setopt(c->curl, CURLOPT_NOSIGNAL, 1L);
215+
curl_easy_setopt(c->curl, CURLOPT_ERRORBUFFER, c->curl_error_message);
215216
if(c->headers != NULL)
216217
curl_easy_setopt(c->curl, CURLOPT_HTTPHEADER, c->headers);
217218
curl_multi_add_handle(g_curl, c->curl);

natives.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ cell_t CurlErrorString(IPluginContext *pContext, const cell_t *params) {
190190
return 0;
191191
}
192192

193+
cell_t CurlGetErrorMessage(IPluginContext *pContext, const cell_t *params) {
194+
GET_CURL_CONTEXT_MACRO
195+
196+
pContext->StringToLocal(params[2], params[3], context->curl_error_message);
197+
return 0;
198+
}
199+
193200
cell_t CurlVersion(IPluginContext *pContext, const cell_t *params) {
194201
char* version = curl_version();
195202
pContext->StringToLocal(params[1], params[2], version);
@@ -255,5 +262,6 @@ sp_nativeinfo_t MyNatives[] = {
255262
{"Async_CurlVersion", CurlVersion},
256263
{"Async_CurlGetResponseHeaderSize", CurlGetResponseHeaderSize},
257264
{"Async_CurlGetResponseHeader", CurlGetResponseHeader},
265+
{"Async_CurlGetErrorMessage", CurlGetErrorMessage},
258266
{NULL, NULL},
259267
};

0 commit comments

Comments
 (0)