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
- DiscoveryServiceExtension.cs
- ClientApiGenerator.cs
- SystemTcpConnection.cs
- BasicExpandProvider.cs
- SqlDependencyListener.cs
- InvokePattern.cs
- DataColumnMapping.cs
- TypeConverterBase.cs
- WorkflowInstance.cs
- SerializationStore.cs
- X509SecurityTokenProvider.cs
- SafeCryptoHandles.cs
- RecognizedWordUnit.cs
- SerializerProvider.cs
- DiagnosticsConfiguration.cs
- BaseDataList.cs
- UnmanagedMarshal.cs
- HttpResponse.cs
- NativeCompoundFileAPIs.cs
- ListViewItem.cs
- FontDialog.cs
- InkPresenterAutomationPeer.cs
- FindCompletedEventArgs.cs
- dataprotectionpermission.cs
- ToolStripItemCollection.cs
- SoapTypeAttribute.cs
- FontStretchConverter.cs
- HttpModulesSection.cs
- DropShadowBitmapEffect.cs
- WebPartConnection.cs
- StreamSecurityUpgradeAcceptorBase.cs
- PrintDialog.cs
- NeedSkipTokenVisitor.cs
- TextServicesCompartmentEventSink.cs
- XmlSchemaExporter.cs
- Types.cs
- EmbeddedMailObject.cs
- OleDbConnection.cs
- PolyLineSegment.cs
- HighlightComponent.cs
- HandlerMappingMemo.cs
- SpellerStatusTable.cs
- OperatingSystem.cs
- StorageConditionPropertyMapping.cs
- EntityClassGenerator.cs
- QueryOpcode.cs
- ServicesUtilities.cs
- Assert.cs
- AddIn.cs
- UserPreferenceChangedEventArgs.cs
- ColumnMapTranslator.cs
- mactripleDES.cs
- ISAPIApplicationHost.cs
- Int32Storage.cs
- Boolean.cs
- ToolStripItemCollection.cs
- HttpProtocolReflector.cs
- GenerateTemporaryTargetAssembly.cs
- Matrix3DConverter.cs
- FieldMetadata.cs
- TransactionBridge.cs
- XmlUtil.cs
- TextTreeExtractElementUndoUnit.cs
- Light.cs
- Stack.cs
- TextTreeTextNode.cs
- MultiView.cs
- PluralizationServiceUtil.cs
- WsdlInspector.cs
- PrintingPermissionAttribute.cs
- WebPartMenuStyle.cs
- MessageQueueConverter.cs
- EventLogWatcher.cs
- WebControl.cs
- ResourceType.cs
- FolderBrowserDialog.cs
- RangeContentEnumerator.cs
- InvalidComObjectException.cs
- ButtonStandardAdapter.cs
- ConsoleTraceListener.cs
- DiscoveryClientProtocol.cs
- BypassElementCollection.cs
- FormsAuthenticationUserCollection.cs
- DeploymentSectionCache.cs
- RoutedEventHandlerInfo.cs
- WindowsAuthenticationEventArgs.cs
- WindowsScrollBar.cs
- HMACSHA384.cs
- AssemblyCache.cs
- SchemaRegistration.cs
- ProxySimple.cs
- Sql8ExpressionRewriter.cs
- DrawingCollection.cs
- TakeQueryOptionExpression.cs
- HttpDebugHandler.cs
- OutOfMemoryException.cs
- ValidationResult.cs
- WindowsListViewGroup.cs
- SqlAliasesReferenced.cs
- ValueQuery.cs