-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDefaultHttpContent.cs
67 lines (50 loc) · 2.01 KB
/
DefaultHttpContent.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) Microsoft. All rights reserved.
// Copyright (c) Ikpil Choi ikpil@naver.com All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ConvertToAutoProperty
namespace UniNetty.Codecs.Http
{
using System.Diagnostics.Contracts;
using UniNetty.Buffers;
using UniNetty.Common;
using UniNetty.Common.Utilities;
public class DefaultHttpContent : DefaultHttpObject, IHttpContent
{
readonly IByteBuffer content;
public DefaultHttpContent(IByteBuffer content)
{
Contract.Requires(content != null);
this.content = content;
}
public IByteBuffer Content => this.content;
public IByteBufferHolder Copy() => this.Replace(this.content.Copy());
public IByteBufferHolder Duplicate() => this.Replace(this.content.Duplicate());
public IByteBufferHolder RetainedDuplicate() => this.Replace(this.content.RetainedDuplicate());
public virtual IByteBufferHolder Replace(IByteBuffer buffer) => new DefaultHttpContent(buffer);
public int ReferenceCount => this.content.ReferenceCount;
public IReferenceCounted Retain()
{
this.content.Retain();
return this;
}
public IReferenceCounted Retain(int increment)
{
this.content.Retain(increment);
return this;
}
public IReferenceCounted Touch()
{
this.content.Touch();
return this;
}
public IReferenceCounted Touch(object hint)
{
this.content.Touch(hint);
return this;
}
public bool Release() => this.content.Release();
public bool Release(int decrement) => this.content.Release(decrement);
public override string ToString() => $"{StringUtil.SimpleClassName(this)} (data: {this.content}, decoderResult: {this.Result})";
}
}