-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExampleRequestHandler.groovy
39 lines (30 loc) · 1.11 KB
/
ExampleRequestHandler.groovy
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
package dist
import org.simpleframework.http.Request
/**
* This is the method XMattersHttpSimulator will invoke after receiving a Request.
* You can optionally return a simulated Http code using 'HttpStatus' as the key.
*/
Map handleRequest(Request request) {
// get all request attribute map
Map attributes = request.attributes
println(attributes)
// get the client address
InetSocketAddress clientAddress = request.clientAddress
println(clientAddress)
// get the request content
String content = request.content
println(content)
// get the request content
println(request.getParameter("paraName"))
// get a request attribute given a key of type Object
Object attr = "abc"
println("get ${attr}: ${request.getAttribute(attr)}")
// get a list of cookies
List<org.simpleframework.http.Cookie> cookies = request.cookies
println("cookies: ${cookies}")
// get the content type
org.simpleframework.http.ContentType contentType = request.contentType
println("contentType.charset=${contentType?.charset}")
int rc = 200
return [HttpStatus: rc]
}