Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- loginstatus.cs
- XmlILOptimizerVisitor.cs
- ExtensionsSection.cs
- BitmapEffectGroup.cs
- DependencyObjectProvider.cs
- EventHandlerList.cs
- DataListCommandEventArgs.cs
- PaperSource.cs
- SafeBitVector32.cs
- JoinQueryOperator.cs
- SeekStoryboard.cs
- relpropertyhelper.cs
- XmlExtensionFunction.cs
- ActivityInfo.cs
- RuntimeArgumentHandle.cs
- DataBindEngine.cs
- PathSegmentCollection.cs
- DecryptedHeader.cs
- DeclarativeExpressionConditionDeclaration.cs
- ActivityTrace.cs
- LiteralControl.cs
- ContentHostHelper.cs
- PreProcessInputEventArgs.cs
- DataGridViewLinkCell.cs
- ValueConversionAttribute.cs
- MSAAWinEventWrap.cs
- ToolboxBitmapAttribute.cs
- ComPlusAuthorization.cs
- ParsedAttributeCollection.cs
- Propagator.JoinPropagator.cs
- GB18030Encoding.cs
- WbemException.cs
- Array.cs
- Buffer.cs
- RegionData.cs
- SimpleWebHandlerParser.cs
- ClipboardProcessor.cs
- PagesSection.cs
- DependencySource.cs
- ServicesExceptionNotHandledEventArgs.cs
- CustomAttributeFormatException.cs
- DesignerCalendarAdapter.cs
- PartialCachingControl.cs
- LayoutTableCell.cs
- UnsafeNativeMethods.cs
- hresults.cs
- TemplateBamlTreeBuilder.cs
- returneventsaver.cs
- SizeConverter.cs
- ISAPIApplicationHost.cs
- BrushValueSerializer.cs
- StreamAsIStream.cs
- Parsers.cs
- NegationPusher.cs
- SqlBulkCopy.cs
- EventLogEntry.cs
- Serializer.cs
- WindowsFont.cs
- CacheDependency.cs
- DataControlFieldHeaderCell.cs
- UnknownBitmapEncoder.cs
- CopyCodeAction.cs
- Rectangle.cs
- PasswordTextContainer.cs
- MessageEventSubscriptionService.cs
- InkCollectionBehavior.cs
- ExceptionUtil.cs
- DurableInstanceProvider.cs
- ApplicationFileCodeDomTreeGenerator.cs
- SynchronizationContext.cs
- Attributes.cs
- RuntimeWrappedException.cs
- HttpFileCollection.cs
- TagPrefixCollection.cs
- Misc.cs
- MetadataItemCollectionFactory.cs
- BindingsCollection.cs
- StringSource.cs
- OutputChannel.cs
- AdapterDictionary.cs
- ExceptionTranslationTable.cs
- VariableExpressionConverter.cs
- RoutedEventConverter.cs
- ControlTemplate.cs
- ViewStateModeByIdAttribute.cs
- DBCSCodePageEncoding.cs
- GeometryGroup.cs
- XhtmlBasicListAdapter.cs
- ShapeTypeface.cs
- HtmlShimManager.cs
- TabItemWrapperAutomationPeer.cs
- DtcInterfaces.cs
- OutputCacheProfile.cs
- HttpHandlerActionCollection.cs
- IOException.cs
- DbTransaction.cs
- SchemaImporterExtensionElementCollection.cs
- ConfigurationLocation.cs
- SqlFlattener.cs
- RelationshipDetailsRow.cs