Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataWeb / Client / System / Data / Services / Client / WebUtil.cs / 2 / 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
- FileLoadException.cs
- InfoCardXmlSerializer.cs
- DistinctQueryOperator.cs
- FloaterBaseParagraph.cs
- ObjectMemberMapping.cs
- CacheSection.cs
- CharStorage.cs
- ToolStripContextMenu.cs
- WebServiceParameterData.cs
- HtmlHead.cs
- PageHandlerFactory.cs
- BitStack.cs
- HtmlSelect.cs
- ProxyWebPartConnectionCollection.cs
- Int16AnimationBase.cs
- SignedPkcs7.cs
- ByteAnimationUsingKeyFrames.cs
- UrlRoutingModule.cs
- CommandDevice.cs
- _ConnectStream.cs
- SqlXml.cs
- XmlIgnoreAttribute.cs
- ConditionalAttribute.cs
- BitmapEffectGroup.cs
- JsonObjectDataContract.cs
- DataContractAttribute.cs
- Size3D.cs
- FileDataSourceCache.cs
- HandoffBehavior.cs
- OutOfProcStateClientManager.cs
- SqlConnectionManager.cs
- Binding.cs
- Exceptions.cs
- BufferBuilder.cs
- ConfigXmlSignificantWhitespace.cs
- Page.cs
- CacheSection.cs
- GeneralTransform3DGroup.cs
- ChannelListenerBase.cs
- XmlObjectSerializerContext.cs
- FontStretch.cs
- _LocalDataStore.cs
- COM2PropertyBuilderUITypeEditor.cs
- CompatibleComparer.cs
- XmlDataImplementation.cs
- RequestTimeoutManager.cs
- UrlAuthFailedErrorFormatter.cs
- DataContractJsonSerializerOperationBehavior.cs
- KeyedHashAlgorithm.cs
- CellCreator.cs
- PropertyIDSet.cs
- cryptoapiTransform.cs
- XmlQueryTypeFactory.cs
- HtmlInputFile.cs
- HandleRef.cs
- HttpApplication.cs
- PropertyConverter.cs
- SQLUtility.cs
- CompositeScriptReferenceEventArgs.cs
- WorkflowMarkupSerializationProvider.cs
- ControlCodeDomSerializer.cs
- CodeGroup.cs
- CanonicalXml.cs
- OperationContextScope.cs
- ContextProperty.cs
- ValuePatternIdentifiers.cs
- ScriptingProfileServiceSection.cs
- RSAPKCS1SignatureDeformatter.cs
- TableCell.cs
- BinaryExpressionHelper.cs
- ProcessModule.cs
- FileEnumerator.cs
- CopyOfAction.cs
- TimeZone.cs
- BinaryObjectReader.cs
- FileUtil.cs
- DbgCompiler.cs
- CultureInfoConverter.cs
- OdbcEnvironmentHandle.cs
- SqlXml.cs
- RayMeshGeometry3DHitTestResult.cs
- QuaternionRotation3D.cs
- TextureBrush.cs
- OrderPreservingMergeHelper.cs
- PropertyEmitter.cs
- SqlCachedBuffer.cs
- CompilationLock.cs
- DrawingState.cs
- ComponentConverter.cs
- SHA1.cs
- FormsAuthenticationModule.cs
- MULTI_QI.cs
- ObjectDataSourceFilteringEventArgs.cs
- DateTimeEditor.cs
- XmlDocumentFragment.cs
- SqlDependencyListener.cs
- WebPartVerbsEventArgs.cs
- ObjectSpanRewriter.cs
- BamlLocalizableResource.cs
- ColorKeyFrameCollection.cs