-
-
Notifications
You must be signed in to change notification settings - Fork 193
Expand file tree
/
Copy pathCefResponse.java
More file actions
130 lines (106 loc) · 3.51 KB
/
CefResponse.java
File metadata and controls
130 lines (106 loc) · 3.51 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
package org.cef.network;
import org.cef.handler.CefLoadHandler.ErrorCode;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
/**
* Class used to represent a web response. The methods of this class may be
* called on any thread.
*/
public abstract class CefResponse {
// This CTOR can't be called directly. Call method create() instead.
CefResponse() {}
@Override
protected void finalize() throws Throwable {
dispose();
super.finalize();
}
/**
* Create a new CefRequest object.
*/
public static final CefResponse create() {
return CefResponse_N.createNative();
}
/**
* Removes the native reference from an unused object.
*/
public abstract void dispose();
/**
* Returns true if this object is read-only.
*/
public abstract boolean isReadOnly();
/**
* Get the response error code. Returns ERR_NONE if there was no error.
*/
public abstract ErrorCode getError();
/**
* Get the response error code. Returns ERR_NONE if there was no error.
*/
public abstract void setError(ErrorCode errorCode);
/**
* Get the response status code.
*/
public abstract int getStatus();
/**
* Set the response status code.
*/
public abstract void setStatus(int status);
/**
* Get the response status text.
*/
public abstract String getStatusText();
/**
* Set the response status text.
*/
public abstract void setStatusText(String statusText);
/**
* Get the response mime type.
*/
public abstract String getMimeType();
/**
* Set the response mime type.
*/
public abstract void setMimeType(String mimeType);
/**
* Get the value for the specified response header field. Use getHeaderMap instead if there
* might be multiple values.
* @param name The header name.
* @return The header value.
*/
public abstract String getHeaderByName(String name);
/**
* Set the value for the specified response header field.
* @param name The header name.
* @param value The header value.
* @param overwrite If true any existing values will be replaced with the new value. If false
* any existing values will not be overwritten.
*/
public abstract void setHeaderByName(String name, String value, boolean overwrite);
/**
* Get all response header fields.
*/
public abstract void getHeaderMap(Map<String, String> headerMap);
/**
* Set all response header fields.
*/
public abstract void setHeaderMap(Map<String, String> headerMap);
@Override
public String toString() {
String returnValue = "\nHTTP-Response:";
returnValue += "\n error: " + getError();
returnValue += "\n readOnly: " + isReadOnly();
returnValue += "\n HTTP/1.1 " + getStatus() + " " + getStatusText();
returnValue += "\n Content-Type: " + getMimeType();
Map<String, String> headerMap = new HashMap<>();
getHeaderMap(headerMap);
Set<Entry<String, String>> entrySet = headerMap.entrySet();
for (Entry<String, String> entry : entrySet) {
returnValue += " " + entry.getKey() + "=" + entry.getValue() + "\n";
}
return returnValue;
}
}