forked from rainliu/sip
/
ContentEncodingImpl.go
105 lines (96 loc) · 3.19 KB
/
ContentEncodingImpl.go
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package header
import (
"errors"
"sip/core"
)
/**
* Content encoding part of a content encoding header list.
*@see ContentEncodingList
*<pre>
* From HTTP RFC 2616
*14.11 Content-Encoding
*
* The Content-Encoding entity-header field is used as a modifier to the
* media-type. When present, its value indicates what additional content
* codings have been applied to the entity-body, and thus what decoding
* mechanisms must be applied in order to obtain the media-type
* referenced by the Content-Type header field. Content-Encoding is
* primarily used to allow a document to be compressed without losing
* the identity of its underlying media type.
*
* Content-Encoding = "Content-Encoding" ":" 1#content-coding
*
* Content codings are defined in section 3.5. An example of its use is
*
* Content-Encoding: gzip
*
* The content-coding is a characteristic of the entity identified by
* the Request-URI. Typically, the entity-body is stored with this
* encoding and is only decoded before rendering or analogous usage.
* However, a non-transparent proxy MAY modify the content-coding if the
* new coding is known to be acceptable to the recipient, unless the
* "no-transform" cache-control directive is present in the message.
*
* If the content-coding of an entity is not "identity", then the
* response MUST include a Content-Encoding entity-header (section
* 14.11) that lists the non-identity content-coding(s) used.
*
* If the content-coding of an entity in a request message is not
* acceptable to the origin server, the server SHOULD respond with a
* status code of 415 (Unsupported Media Type).
*
* If multiple encodings have been applied to an entity, the content
* codings MUST be listed in the order in which they were applied.
* Additional information about the encoding parameters MAY be provided
* by other entity-header fields not defined by this specification.
*</pre>
*/
type ContentEncoding struct {
SIPHeader
/** contentEncoding field.
*/
contentEncoding string
}
/** Default constructor.
*/
func NewContentEncoding() *ContentEncoding {
this := &ContentEncoding{}
this.SIPHeader.super(core.SIPHeaderNames_CONTENT_ENCODING)
return this
}
/** constructor.
* @param enc String to set.
*/
func NewContentEncodingFromString(enc string) *ContentEncoding {
this := &ContentEncoding{}
this.SIPHeader.super(core.SIPHeaderNames_CONTENT_ENCODING)
this.contentEncoding = enc
return this
}
func (this *ContentEncoding) String() string {
return this.headerName + core.SIPSeparatorNames_COLON +
core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE
}
/**
* Canonical encoding of body of the header.
* @return encoded body of the header.
*/
func (this *ContentEncoding) EncodeBody() string {
return this.contentEncoding
}
/** get the ContentEncoding field.
* @return String
*/
func (this *ContentEncoding) GetEncoding() string {
return this.contentEncoding
}
/** set the ConentEncoding field.
* @param encoding String to set
*/
func (this *ContentEncoding) SetEncoding(encoding string) (ParseException error) {
if encoding == "" {
return errors.New("NullPointerException: encoding is null")
}
this.contentEncoding = encoding
return nil
}