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
- ListView.cs
- DesignerUtils.cs
- SoapInteropTypes.cs
- ComponentCollection.cs
- DNS.cs
- SmtpLoginAuthenticationModule.cs
- D3DImage.cs
- Visual.cs
- SortDescription.cs
- TextPenaltyModule.cs
- ControlTemplate.cs
- TopClause.cs
- ListViewHitTestInfo.cs
- MyContact.cs
- ApplicationFileParser.cs
- ErasingStroke.cs
- SiteOfOriginContainer.cs
- AnnotationObservableCollection.cs
- DebugHandleTracker.cs
- NamespaceEmitter.cs
- XmlSchemaObject.cs
- Serializer.cs
- QilNode.cs
- UnsafeNetInfoNativeMethods.cs
- validationstate.cs
- DataRelation.cs
- AsymmetricKeyExchangeFormatter.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- MediaTimeline.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- EventBookmark.cs
- MatrixTransform3D.cs
- LongValidatorAttribute.cs
- CultureNotFoundException.cs
- ResourceDescriptionAttribute.cs
- IncrementalReadDecoders.cs
- ActivityDesignerAccessibleObject.cs
- FileDataSourceCache.cs
- CommandConverter.cs
- WriteableBitmap.cs
- ObjectListItem.cs
- SqlConnectionString.cs
- FragmentQueryProcessor.cs
- InputScope.cs
- TiffBitmapDecoder.cs
- IntAverageAggregationOperator.cs
- FieldTemplateFactory.cs
- ProgressiveCrcCalculatingStream.cs
- ConfigXmlComment.cs
- UnsafeNativeMethods.cs
- BitmapPalette.cs
- IPCCacheManager.cs
- CompileXomlTask.cs
- NetworkCredential.cs
- CodeSubDirectoriesCollection.cs
- WebSysDescriptionAttribute.cs
- XmlChildNodes.cs
- BackEase.cs
- HScrollBar.cs
- OdbcErrorCollection.cs
- QueryOperator.cs
- BooleanSwitch.cs
- ViewSimplifier.cs
- SetUserPreferenceRequest.cs
- CompositeControl.cs
- DtdParser.cs
- ProxySimple.cs
- LayoutDump.cs
- TemplateGroupCollection.cs
- ShaderEffect.cs
- ListControlBoundActionList.cs
- ScrollViewer.cs
- XmlElementList.cs
- BeginStoryboard.cs
- DelegatingTypeDescriptionProvider.cs
- CommandLineParser.cs
- CultureTable.cs
- DecimalAverageAggregationOperator.cs
- MethodSignatureGenerator.cs
- FamilyCollection.cs
- InlinedAggregationOperator.cs
- UnaryNode.cs
- SharedStream.cs
- FilteredXmlReader.cs
- XmlBinaryReader.cs
- EnumUnknown.cs
- IncrementalReadDecoders.cs
- ADMembershipProvider.cs
- TextCharacters.cs
- ACE.cs
- StylusPointPropertyInfoDefaults.cs
- PrePrepareMethodAttribute.cs
- ZipIOLocalFileHeader.cs
- PickBranchDesigner.xaml.cs
- PieceDirectory.cs
- XPathDocumentNavigator.cs
- ValuePattern.cs
- Odbc32.cs
- GroupByQueryOperator.cs
- NativeMethods.cs