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
- PropertyItem.cs
- LoadedOrUnloadedOperation.cs
- VectorCollectionValueSerializer.cs
- EndPoint.cs
- ContainsRowNumberChecker.cs
- _KerberosClient.cs
- BuildProviderUtils.cs
- SystemWebCachingSectionGroup.cs
- CodeCommentStatementCollection.cs
- ErrorView.xaml.cs
- DataGridViewColumn.cs
- DataRecordObjectView.cs
- WindowCollection.cs
- ConstrainedDataObject.cs
- ObjectListComponentEditor.cs
- TreeNodeCollectionEditorDialog.cs
- SQLSingle.cs
- DataMemberFieldEditor.cs
- XmlSchemaImport.cs
- FontFamily.cs
- ReceiveSecurityHeader.cs
- TextWriterEngine.cs
- DesignerTransaction.cs
- WorkflowMarkupElementEventArgs.cs
- _UriTypeConverter.cs
- GZipDecoder.cs
- BinarySecretSecurityToken.cs
- TableAutomationPeer.cs
- EncoderExceptionFallback.cs
- FixUpCollection.cs
- DatatypeImplementation.cs
- DesignerTransaction.cs
- MaterialCollection.cs
- MetadataElement.cs
- SoapException.cs
- GenericTypeParameterBuilder.cs
- mediaeventargs.cs
- Geometry3D.cs
- PropertyEntry.cs
- DataRecord.cs
- WebDisplayNameAttribute.cs
- RegexReplacement.cs
- Point3DCollection.cs
- ImageConverter.cs
- AccessDataSourceDesigner.cs
- GridLength.cs
- MarkupCompilePass2.cs
- HttpCookiesSection.cs
- CompiledELinqQueryState.cs
- ResourceIDHelper.cs
- ProjectionPath.cs
- HtmlUtf8RawTextWriter.cs
- ObjectQueryProvider.cs
- XmlDocument.cs
- SqlDataSourceFilteringEventArgs.cs
- HttpHandlerAction.cs
- CellRelation.cs
- _Win32.cs
- PersonalizationProvider.cs
- DirectoryInfo.cs
- OleAutBinder.cs
- ProfileElement.cs
- XPathQueryGenerator.cs
- LineProperties.cs
- OdbcUtils.cs
- InternalUserCancelledException.cs
- VarRefManager.cs
- RotateTransform3D.cs
- SchemaTableColumn.cs
- FormattedTextSymbols.cs
- MetadataItem_Static.cs
- NameTable.cs
- EntityReference.cs
- SchemaHelper.cs
- TargetInvocationException.cs
- CodeIdentifiers.cs
- DataControlPagerLinkButton.cs
- SamlSerializer.cs
- FileLevelControlBuilderAttribute.cs
- IPAddress.cs
- UserControlParser.cs
- TryCatchDesigner.xaml.cs
- PriorityItem.cs
- SqlMethodCallConverter.cs
- XmlNamedNodeMap.cs
- MenuEventArgs.cs
- GenericPrincipal.cs
- MemberRelationshipService.cs
- SharedDp.cs
- VirtualizingPanel.cs
- MessageQueuePermission.cs
- BamlResourceDeserializer.cs
- HashCryptoHandle.cs
- PageSetupDialog.cs
- CodeEventReferenceExpression.cs
- TabPage.cs
- CodeMethodReturnStatement.cs
- Scene3D.cs
- Avt.cs
- FlowPosition.cs