Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataWeb / Client / System / Data / Services / Client / WebUtil.cs / 1 / WebUtil.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// static utility functions // //--------------------------------------------------------------------- namespace System.Data.Services.Client { using System.Collections.Generic; using System.Diagnostics; using System.IO; #if !ASTORIA_LIGHT // Data.Services http stack using System.Net; #else using System.Data.Services.Http; #endif ///web utility functions internal static partial class WebUtil { ///copy from one stream to another /// input stream /// output stream /// reusable buffer ///count of copied bytes internal static long CopyStream(Stream input, Stream output, ref byte[] refBuffer) { Debug.Assert(null != input, "null input stream"); Debug.Assert(null != output, "null output stream"); long total = 0; byte[] buffer = refBuffer; if (null == buffer) { refBuffer = buffer = new byte[1000]; } int count = 0; while (input.CanRead && (0 < (count = input.Read(buffer, 0, buffer.Length)))) { output.Write(buffer, 0, count); total += count; } return total; } ///get response object from possible WebException /// exception to probe /// http web respose object from exception internal static void GetHttpWebResponse(InvalidOperationException exception, ref HttpWebResponse response) { if (null == response) { WebException webexception = (exception as WebException); if (null != webexception) { response = (HttpWebResponse)webexception.Response; } } } ///is this a success status code /// status code ///true if status is between 200-299 internal static bool SuccessStatusCode(HttpStatusCode status) { return (200 <= (int)status && (int)status < 300); } ////// turn the response object headers into a dictionary /// /// response ///dictionary internal static DictionaryWrapResponseHeaders(HttpWebResponse response) { Dictionary headers = new Dictionary (); if (null != response) { foreach (string name in response.Headers.AllKeys) { headers.Add(name, response.Headers[name]); } } return headers; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // //// static utility functions // //--------------------------------------------------------------------- namespace System.Data.Services.Client { using System.Collections.Generic; using System.Diagnostics; using System.IO; #if !ASTORIA_LIGHT // Data.Services http stack using System.Net; #else using System.Data.Services.Http; #endif ///web utility functions internal static partial class WebUtil { ///copy from one stream to another /// input stream /// output stream /// reusable buffer ///count of copied bytes internal static long CopyStream(Stream input, Stream output, ref byte[] refBuffer) { Debug.Assert(null != input, "null input stream"); Debug.Assert(null != output, "null output stream"); long total = 0; byte[] buffer = refBuffer; if (null == buffer) { refBuffer = buffer = new byte[1000]; } int count = 0; while (input.CanRead && (0 < (count = input.Read(buffer, 0, buffer.Length)))) { output.Write(buffer, 0, count); total += count; } return total; } ///get response object from possible WebException /// exception to probe /// http web respose object from exception internal static void GetHttpWebResponse(InvalidOperationException exception, ref HttpWebResponse response) { if (null == response) { WebException webexception = (exception as WebException); if (null != webexception) { response = (HttpWebResponse)webexception.Response; } } } ///is this a success status code /// status code ///true if status is between 200-299 internal static bool SuccessStatusCode(HttpStatusCode status) { return (200 <= (int)status && (int)status < 300); } ////// turn the response object headers into a dictionary /// /// response ///dictionary internal static DictionaryWrapResponseHeaders(HttpWebResponse response) { Dictionary headers = new Dictionary (); if (null != response) { foreach (string name in response.Headers.AllKeys) { headers.Add(name, response.Headers[name]); } } return headers; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridRow.cs
- Profiler.cs
- ActivityExecutionFilter.cs
- PropertyGroupDescription.cs
- FrugalList.cs
- AssociatedControlConverter.cs
- ValidationContext.cs
- SmiMetaDataProperty.cs
- TrackingStringDictionary.cs
- BinarySerializer.cs
- ConfigurationSectionGroupCollection.cs
- TableItemPatternIdentifiers.cs
- UdpUtility.cs
- RSACryptoServiceProvider.cs
- FloaterBaseParagraph.cs
- SpecularMaterial.cs
- NativeRecognizer.cs
- WebPartTransformerCollection.cs
- InkCanvasSelectionAdorner.cs
- TimeSpanOrInfiniteConverter.cs
- DataGridViewUtilities.cs
- StaticTextPointer.cs
- COSERVERINFO.cs
- SortDescriptionCollection.cs
- x509store.cs
- XmlChildEnumerator.cs
- _Rfc2616CacheValidators.cs
- EntityContainer.cs
- GlyphElement.cs
- _Win32.cs
- AdRotator.cs
- RoutedEventConverter.cs
- HelloMessageApril2005.cs
- Compress.cs
- ManagementQuery.cs
- ContentType.cs
- DSACryptoServiceProvider.cs
- SwitchAttribute.cs
- WebServiceEndpoint.cs
- SqlNodeAnnotation.cs
- ConfigXmlElement.cs
- ValidationErrorInfo.cs
- XsdCachingReader.cs
- GenericEnumConverter.cs
- Int16.cs
- CreateUserWizard.cs
- CharEnumerator.cs
- SchemaCollectionCompiler.cs
- ToolboxItemCollection.cs
- SqlStatistics.cs
- RangeBaseAutomationPeer.cs
- DeferredTextReference.cs
- TableChangeProcessor.cs
- SelectionItemPatternIdentifiers.cs
- xmlglyphRunInfo.cs
- mactripleDES.cs
- WSSecurityOneDotZeroReceiveSecurityHeader.cs
- OleDbRowUpdatingEvent.cs
- CodeRegionDirective.cs
- ConfigurationSchemaErrors.cs
- precedingquery.cs
- DefaultPropertyAttribute.cs
- WebBaseEventKeyComparer.cs
- TypeDescriptionProvider.cs
- odbcmetadatacollectionnames.cs
- ImageClickEventArgs.cs
- PreProcessInputEventArgs.cs
- WebServiceResponseDesigner.cs
- SettingsPropertyCollection.cs
- SafeCoTaskMem.cs
- CultureInfo.cs
- KeyboardNavigation.cs
- SettingsAttributeDictionary.cs
- BindingManagerDataErrorEventArgs.cs
- Oid.cs
- GradientBrush.cs
- RequiredFieldValidator.cs
- Event.cs
- LOSFormatter.cs
- IERequestCache.cs
- IPAddressCollection.cs
- DataListCommandEventArgs.cs
- Array.cs
- ProxyAttribute.cs
- DataGridViewTextBoxColumn.cs
- ComponentChangedEvent.cs
- FixedHyperLink.cs
- ExpandSegmentCollection.cs
- Maps.cs
- XPathNodeHelper.cs
- XmlName.cs
- DrawingVisualDrawingContext.cs
- LOSFormatter.cs
- PreviewPrintController.cs
- X509CertificateRecipientClientCredential.cs
- sitestring.cs
- xdrvalidator.cs
- ObjectSelectorEditor.cs
- XmlResolver.cs
- InplaceBitmapMetadataWriter.cs