4343#define PARSE_INSTALLATION_ID "installationID"
4444#define PARSE_SESSION_TOKEN "sessionToken"
4545#define PARSE_LAST_PUSH_TIME "lastPushTime"
46+ #define PARSE_DEFAULT_SERVER_URL "https://api.parse.com"
4647
4748typedef struct _ParseClientInternal {
4849 const char * applicationId ;
@@ -52,6 +53,7 @@ typedef struct _ParseClientInternal {
5253 char * sessionToken ;
5354 char * osVersion ;
5455 char * lastPushTime ;
56+ char * serverURL ;
5557 parsePushCallback pushCallback ;
5658 CURL * pushCurlHandle ;
5759 unsigned long long lastHearbeat ;
@@ -118,9 +120,10 @@ static size_t curlDataCallback(void *contents, size_t size, size_t nmemb, void *
118120 return size * nmemb ;
119121}
120122
121- ParseClient parseInitialize (
123+ ParseClient parseInitializeWithServerURL (
122124 const char * applicationId ,
123- const char * clientKey )
125+ const char * clientKey ,
126+ const char * serverURL )
124127{
125128 parseSetLogLevel (PARSE_LOG_WARN );
126129
@@ -134,6 +137,11 @@ ParseClient parseInitialize(
134137 if (clientKey != NULL )
135138 client -> clientKey = strdup (clientKey );
136139
140+ if (serverURL != NULL )
141+ client -> serverURL = strdup (serverURL );
142+ else if (serverURL == NULL )
143+ client -> serverURL = strdup (PARSE_DEFAULT_SERVER_URL );
144+
137145 char version [256 ];
138146 parseOsGetVersion (version , sizeof (version ));
139147 client -> osVersion = strdup (version );
@@ -159,6 +167,13 @@ ParseClient parseInitialize(
159167 return (ParseClient )client ;
160168}
161169
170+ ParseClient parseInitialize (
171+ const char * applicationId ,
172+ const char * clientKey )
173+ {
174+ return parseInitializeWithServerURL (applicationId , clientKey , NULL );
175+ }
176+
162177static void setInstallationCallback (ParseClient client , int error , int httpStatus , const char * httpResponseBody )
163178{
164179 if (error != 0 ) {
@@ -539,7 +554,7 @@ static void parseSendRequestInternal(
539554 }
540555 }
541556
542- int urlSize = strlen ("https://api.parse.com" );
557+ int urlSize = strlen (clientInternal -> serverURL );
543558 urlSize += strlen (httpPath ) + 1 ;
544559 char * getEncodedBody = NULL ;
545560 if (getRequestBody ) {
@@ -551,7 +566,15 @@ static void parseSendRequestInternal(
551566 if (callback != NULL ) callback (client , ENOMEM , 0 , NULL );
552567 return ;
553568 }
554- strncat (fullUrl , "https://api.parse.com" , urlSize );
569+
570+ if (clientInternal -> serverURL != NULL ){
571+ strncat (fullUrl , clientInternal -> serverURL , urlSize );
572+ }
573+ else {
574+ strncat (fullUrl , PARSE_DEFAULT_SERVER_URL , urlSize );
575+ }
576+
577+
555578 strncat (fullUrl , httpPath , urlSize - strlen (fullUrl ));
556579 if (getRequestBody ) {
557580 strncat (fullUrl , "?" , urlSize - strlen (fullUrl ));
0 commit comments