public void GetEncodedBytes_default_ascii() { var actual = IorClient.GetEncodedBytes("echo", "", true); var expected = new byte[] { 0x65, 0x63, 0x68, 0x6F }; actual.ShouldBeEquivalentTo(expected); }
public void GetEncodedBytes_utf8_bom() { var actual = IorClient.GetEncodedBytes("echo", "utf-8", true); var expected = new byte[] { 0xEF, 0xBB, 0xBF, 0x65, 0x63, 0x68, 0x6F }; actual.ShouldBeEquivalentTo(expected); }
public void GetEncodedBytes_utf32le() { //le no bom var actual = IorClient.GetEncodedBytes("echo", "utf-32le", false); var expected = new byte[] { 0x65, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00 }; actual.ShouldBeEquivalentTo(expected); }
public void GetEncodedBytes_utf32() { //default big endian w/ bom var actual = IorClient.GetEncodedBytes("echo", "utf-32", false); var expected = new byte[] { 0x00, 0x00, 0xFE, 0xFF, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x6F }; actual.ShouldBeEquivalentTo(expected); }
public void Base64EncodeUrlUserInfo_wikipedia_example_with_space() { var url = new Uri("http://*****:*****@example.com"); var actual = IorClient.Base64EncodeUrlUserInfo(url); var expected = "QWxhZGRpbjpvcGVuIHNlc2FtZQ=="; actual.ShouldBeEquivalentTo(expected); }
private void btnSubmitRequest_Click(object sender, EventArgs e) { resetLogStats(); //build the request view var requestVm = buildRequestViewModel(); //attempt to build the request model from the request view: if we fail, show an error messages, else continue and make the request. RequestModel requestModel = null; var validationErrors = RequestModel.TryCreate(requestVm, out requestModel); if (validationErrors.Count > 0) { //todo: move this to common dialog functionality //add bullets if more than one if (validationErrors.Count > 1) { var buffer = new byte[] { 149 }; string bullet = Encoding.GetEncoding(1252).GetString(buffer); validationErrors = validationErrors.Select(x => bullet + " " + x).ToList(); } showWarning("Request Validation Errors", String.Join(Environment.NewLine, validationErrors)); } else { cancelAsyncRequest(); //clear response view and show loading message status bind(ResponseModel.Loading); grpResponse.Update(); try { var client = new IorClient( Settings.Default.DefaultRequestContentType, Settings.Default.ProxyServer, Settings.Default.IncludeBomInUtf8RequestContent, Settings.Default.FollowRedirects, Settings.Default.EnableAutomaticContentDecompression ); this.requestAsyncHandle = client.ExecuteAsync(requestModel, responseModel => this.Invoke((MethodInvoker) delegate { this.requestAsyncHandle = null; //bind the response view bind(responseModel); addRequestResponseSnapshot(requestVm, responseModel); grpResponse.Update(); }) ); } catch (Exception ex) { log.Error(ex, "There was an error executing the request"); showError("Error", "There was an error executing the request: " + Environment.NewLine + Environment.NewLine + ex.ToString()); //reset the response view (i.e. roll-back loading message") bind(ResponseModel.Empty); grpResponse.Update(); } } }