public void RequestPut <T>( RequestSuccessDelegate <T> success, RequestErrorDelegate fail, string path, object body = null, Dictionary <string, object> queryParams = null, Dictionary <string, string> headers = null ) { HTTPRequest request = new HTTPRequest(CreateUri(path, queryParams), HTTPMethods.Put, delegate(HTTPRequest originalRequest, HTTPResponse httpResponse) { HandleResponse(originalRequest, httpResponse, success, fail); } ); if (body != null) { Debug.Log("CALLING SERVER Uri: " + request.Uri + " Body: " + converter.ToString(body)); } else { Debug.Log("CALLING SERVER Uri: " + request.Uri); } AddHeaders(request, headers); if (body != null) { request.RawData = converter.ToRawData(body); } request.Send(); }
public void RequestGet <T>( RequestSuccessDelegate <T> success, RequestErrorDelegate fail, string path, Dictionary <string, object> queryParams = null, Dictionary <string, string> headers = null ) { HTTPRequest request = new HTTPRequest(CreateUri(path, queryParams), HTTPMethods.Get, delegate(HTTPRequest originalRequest, HTTPResponse httpResponse) { HandleResponse(originalRequest, httpResponse, success, fail); } ); Debug.Log("CALLING SERVER Uri: " + request.Uri); AddHeaders(request, headers); request.Send(); }
private void HandleResponse <T>( HTTPRequest originalRequest, HTTPResponse httpResponse, RequestSuccessDelegate <T> success, RequestErrorDelegate fail ) { Response <T> response = null; try{ Debug.Log("SERVER RESPONSE Uri: " + originalRequest.Uri + " Response: " + httpResponse.DataAsText); response = ProcessResponse <T>(originalRequest, httpResponse); }catch (Exception e) { Debug.Log("INTERNAL ERROR: " + e.Message); fail(e); } if (response != null) { success(response); } }