
com.confluex.mock.http.ClientRequest.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of confluex-mock-http Show documentation
Show all versions of confluex-mock-http Show documentation
Testing library for mocking interactions to external HTTP servers
package com.confluex.mock.http
import groovy.transform.ToString
import javax.servlet.http.HttpServletRequest
@ToString(includeNames=true)
class ClientRequest {
Map headers = [:]
Map queryParams = [:]
String contentType
String body
String method
String url
String path
String queryString
ClientRequest(HttpServletRequest request) {
this.method = request.method
this.contentType = request.contentType
this.body = request.inputStream?.text
this.url = request.requestURL.toString()
this.path = request.pathInfo
this.queryString = request.queryString
request.headerNames.each { String name ->
headers[name] = request.getHeader(name)
}
this.queryString?.split('&').each { queryParam ->
def tuple = queryParam.split('=').collect() { URLDecoder.decode(it) }
queryParams[tuple[0]] = tuple[1]
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy