public RemoteBulkInsertOperation(BulkInsertOptions options, ServerClient client) { this.options = options; this.client = client; items = new BlockingCollection <RavenJObject>(options.BatchSize * 8); string requestUrl = "/bulkInsert?"; if (options.CheckForUpdates) { requestUrl += "checkForUpdates=true"; } if (options.CheckReferencesInIndexes) { requestUrl += "&checkReferencesInIndexes=true"; } var expect100Continue = client.Expect100Continue(); // this will force the HTTP layer to authenticate, meaning that our next request won't have to HttpJsonRequest req = client.CreateRequest("POST", requestUrl + "&op=generate-single-use-auth-token", disableRequestCompression: true); var token = req.ReadResponseJson(); httpJsonRequest = client.CreateRequest("POST", requestUrl, disableRequestCompression: true); // the request may take a long time to process, so we need to set a large timeout value httpJsonRequest.PrepareForLongRequest(); httpJsonRequest.AddOperationHeader("Single-Use-Auth-Token", token.Value <string>("Token")); nextTask = httpJsonRequest.GetRawRequestStream() .ContinueWith(task => { try { expect100Continue.Dispose(); } catch (Exception) { } WriteQueueToServer(task); }); }
public SendCustomRequest() { using (var store = new DocumentStore()) { #region custom_request_1 string key = "employees/1"; // http://localhost:8080/databases/Northwind/docs/employees/1 string url = store.Url // http://localhost:8080 .ForDatabase("Northwind") // /databases/Northwind .Doc(key); // /docs/employees/1 IDatabaseCommands commands = store.DatabaseCommands; using (HttpJsonRequest request = store .JsonRequestFactory .CreateHttpJsonRequest(new CreateHttpJsonRequestParams(commands, url, "GET", commands.PrimaryCredentials, store.Conventions))) { RavenJToken json = request.ReadResponseJson(); JsonDocument jsonDocument = SerializationHelper .DeserializeJsonDocument(key, json, request.ResponseHeaders, request.ResponseStatusCode); } #endregion } }