blob: 7f49acb1496b63d1d358cab59b0d3ab202a7b149 (
plain)
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
|
package org.simpleframework.http.message;
import java.util.List;
import org.simpleframework.http.ContentDisposition;
import org.simpleframework.http.ContentType;
import org.simpleframework.http.message.MessageHeader;
import org.simpleframework.http.message.Segment;
import org.simpleframework.http.parse.ContentDispositionParser;
import org.simpleframework.http.parse.ContentTypeParser;
public class MockSegment implements Segment {
private MessageHeader header;
public MockSegment() {
this.header = new MessageHeader();
}
public boolean isFile() {
return false;
}
public ContentType getContentType() {
String value = getValue("Content-Type");
if(value == null) {
return null;
}
return new ContentTypeParser(value);
}
public long getContentLength() {
String value = getValue("Content-Length");
if(value != null) {
return new Long(value);
}
return -1;
}
public String getTransferEncoding() {
List<String> list = getValues("Transfer-Encoding");
if(list.size() > 0) {
return list.get(0);
}
return null;
}
public ContentDisposition getDisposition() {
String value = getValue("Content-Disposition");
if(value == null) {
return null;
}
return new ContentDispositionParser(value);
}
public List<String> getValues(String name) {
return header.getValues(name);
}
public String getValue(String name) {
return header.getValue(name);
}
public String getValue(String name, int index) {
return header.getValue(name, index);
}
protected void add(String name, String value) {
header.addValue(name, value);
}
public String getName() {
return null;
}
public String getFileName() {
return null;
}
}
|