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
- SystemNetHelpers.cs
- FollowerQueueCreator.cs
- DupHandleConnectionReader.cs
- VirtualPath.cs
- SQLChars.cs
- MaskInputRejectedEventArgs.cs
- ToolStripSystemRenderer.cs
- SystemFonts.cs
- PowerModeChangedEventArgs.cs
- Encoder.cs
- WebScriptEndpointElement.cs
- InputLangChangeRequestEvent.cs
- VariableReference.cs
- TreeBuilderXamlTranslator.cs
- EmissiveMaterial.cs
- PenLineCapValidation.cs
- XmlILOptimizerVisitor.cs
- DataGridSortCommandEventArgs.cs
- TreeViewImageKeyConverter.cs
- ISCIIEncoding.cs
- EncoderNLS.cs
- MetadataArtifactLoaderCompositeResource.cs
- SqlError.cs
- PreDigestedSignedInfo.cs
- WindowsEditBoxRange.cs
- IApplicationTrustManager.cs
- PerspectiveCamera.cs
- ColorInterpolationModeValidation.cs
- LinkButton.cs
- InfoCardClaim.cs
- NavigatorOutput.cs
- SiteIdentityPermission.cs
- RecipientServiceModelSecurityTokenRequirement.cs
- ISFTagAndGuidCache.cs
- RecognizedPhrase.cs
- SqlNodeTypeOperators.cs
- X509Certificate2.cs
- ScriptIgnoreAttribute.cs
- ItemDragEvent.cs
- KeySpline.cs
- SystemFonts.cs
- BCLDebug.cs
- Html32TextWriter.cs
- InternalBase.cs
- PeerObject.cs
- LayoutTable.cs
- Grid.cs
- BitmapEditor.cs
- Graphics.cs
- Button.cs
- OleDbErrorCollection.cs
- UrlAuthFailedErrorFormatter.cs
- NameSpaceExtractor.cs
- DateTimeParse.cs
- safelink.cs
- CapabilitiesSection.cs
- sqlinternaltransaction.cs
- InitiatorServiceModelSecurityTokenRequirement.cs
- MenuScrollingVisibilityConverter.cs
- BindingElementExtensionElement.cs
- TabControlCancelEvent.cs
- SequenceDesigner.cs
- CqlErrorHelper.cs
- XMLUtil.cs
- PartitionedStream.cs
- XmlSchemaGroupRef.cs
- ObjectSet.cs
- AuthorizationRuleCollection.cs
- DynamicResourceExtension.cs
- FontCacheUtil.cs
- DesignBindingEditor.cs
- ArgumentOutOfRangeException.cs
- QuotedStringWriteStateInfo.cs
- DataProtection.cs
- FontFamily.cs
- DataServiceRequestException.cs
- ClientSponsor.cs
- TreeNodeStyleCollection.cs
- _Semaphore.cs
- TextRenderingModeValidation.cs
- FillRuleValidation.cs
- ToolboxBitmapAttribute.cs
- AssociationTypeEmitter.cs
- RouteItem.cs
- WebServiceFault.cs
- DataGridCommandEventArgs.cs
- selecteditemcollection.cs
- ProfessionalColors.cs
- Context.cs
- LinqDataSourceInsertEventArgs.cs
- PersistNameAttribute.cs
- XXXOnTypeBuilderInstantiation.cs
- SqlUdtInfo.cs
- SmiSettersStream.cs
- StylusPointDescription.cs
- UIElementAutomationPeer.cs
- CatalogPart.cs
- EngineSiteSapi.cs
- AdornerLayer.cs
- QueryResults.cs