public class Request extends Object
| Constructor and Description |
|---|
Request(org.ballerinalang.jvm.values.ObjectValue requestObj) |
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(String headerName,
String headerValue)
Adds the specified header to the request.
|
boolean |
expects100Continue()
Checks whether the client expects a `100-continue` response.
|
byte[] |
getBinaryPayload()
Gets the request payload as a `byte[]`.
|
Entity[] |
getBodyParts()
Extracts body parts from the request.
|
ByteChannel |
getByteChannel()
Gets the request payload as a `ByteChannel` except in the case of multiparts.
|
String |
getContentType()
Gets the type of the payload of the request (i.e: the `content-type` header value).
|
Entity |
getEntity() |
Entity |
getEntityWithoutBody() |
String |
getHeader(String headerName)
Returns the value of the specified header.
|
String[] |
getHeaderNames()
Gets all the names of the headers of the request.
|
String[] |
getHeaders(String headerName)
Gets all the header values to which the specified header key maps to.
|
org.json.JSONArray |
getJsonArrayPayload()
Extracts `json array` payload from the request.
|
org.json.JSONObject |
getJsonPayload()
Extracts `json` payload from the request.
|
Map<String,String> |
getMatrixParams(String path)
Gets the matrix parameters of the request.
|
org.ballerinalang.jvm.values.ObjectValue |
getNativeRequestObject()
Returns the java native object of the ballerina level http:Request object.
|
String |
getPathInfo()
Gets the additional path information available in the request.
|
Map<String,String> |
getPathParams()
Gets the path parameters of the request as a map.
|
Map<String,String> |
getQueryParams()
Gets the query parameters of the request as a map.
|
String |
getQueryParamValue(String key)
Gets the query param value associated with the given key.
|
String[] |
getQueryParamValues(String key)
Gets all the query param values associated with the given key.
|
String |
getRequestHttpMethod()
Gets the requested resource http method.
|
String |
getRequestHttpVersion()
Gets the http version used for the request.
|
String |
getRequestPath()
Gets the requested resource path.
|
String |
getTextPayload()
Extracts `text` payload from the request.
|
String |
getUserAgent()
Gets the request user agent details.
|
org.ballerinalang.jvm.values.api.BXML |
getXmlPayload()
Extracts `xml` payload from the request.
|
boolean |
hasHeader(String headerName)
Checks whether the requested header key exists in the header map.
|
void |
removeAllHeaders()
Removes all the headers from the request.
|
void |
removeHeader(String headerName)
Removes the specified header from the request.
|
void |
setBinaryPayload(byte[] binaryPayload)
Sets a byte[] content as the payload.
|
void |
setBodyParts(Entity[] bodyParts,
String contentType)
Set multiparts as the payload.
|
void |
setByteChannel(org.ballerinalang.stdlib.io.channels.base.Channel byteChannel,
String contentType)
Set byte channel as the payload.
|
void |
setContentType(String contentType)
Sets the `content-type` header to the request.
|
void |
setEntity(Entity entity) |
void |
setHeader(String headerName,
String headerValue)
Sets the specified header to the request.
|
void |
setJsonPayload(org.json.JSONArray jsonArrayPayload)
Sets a json array
JSONArray as the payload to the request. |
void |
setJsonPayload(org.json.JSONObject jsonPayload)
Sets a json
JSONObject as the payload to the request. |
void |
setTextPayload(String textPayload)
Sets a string text content as the payload.
|
void |
setXmlPayload(org.ballerinalang.jvm.values.api.BXML xmlPayload)
Sets a xml as the payload.
|
public String getRequestPath()
public String getRequestHttpMethod()
public String getRequestHttpVersion()
public String getPathInfo()
public String getUserAgent()
public Map<String,String> getPathParams()
Map Map of path parameters. Map with size 0 is returned if path parameters does not present.public Map<String,String> getQueryParams()
Map map containing query parameters.public String getQueryParamValue(String key)
key - Represents the query param key.public String[] getQueryParamValues(String key)
key - Represents the query param key.public Map<String,String> getMatrixParams(String path)
path - Path to the location of matrix parameters.MapValue of matrix parameters which can be found for the given path.public boolean hasHeader(String headerName)
headerName - The header name.public String getHeader(String headerName)
headerName - The header name.public String[] getHeaders(String headerName)
headerName - The header name.public void setHeader(String headerName, String headerValue)
headerName - The header name.headerValue - The header value.public void addHeader(String headerName, String headerValue)
headerName - The header name.headerValue - The header value.public void removeHeader(String headerName)
headerName - The header name.public void removeAllHeaders()
public String[] getHeaderNames()
public boolean expects100Continue()
public void setContentType(String contentType)
contentType - Content type value to be set as the `content-type` header.public String getContentType()
public org.json.JSONObject getJsonPayload()
throws InterceptorException
JSONObject payload of the request. Null if json body is not found in the request.InterceptorException - If error while getting json payload.public org.json.JSONArray getJsonArrayPayload()
throws InterceptorException
JSONArray payload of the request. Null if json body is not found in the request.InterceptorException - If error while getting json payload.public org.ballerinalang.jvm.values.api.BXML getXmlPayload()
throws InterceptorException
BXML The `xml` payload of the request.InterceptorException - If error while getting xml payload.public String getTextPayload() throws InterceptorException
InterceptorException - If error while getting text payload.public ByteChannel getByteChannel() throws InterceptorException
ByteChannel A byte channel from which the message payload can be read.InterceptorException - If error while getting byte channel of the request.public byte[] getBinaryPayload()
throws InterceptorException
InterceptorException - If error while getting byte array of the request.public Entity[] getBodyParts() throws InterceptorException
InterceptorException - if there were any errors constructing the body parts from the request.public void setJsonPayload(org.json.JSONObject jsonPayload)
JSONObject as the payload to the request.jsonPayload - JSONObject The json payload.public void setJsonPayload(org.json.JSONArray jsonArrayPayload)
JSONArray as the payload to the request.jsonArrayPayload - JSONArray The json array payload.public void setXmlPayload(org.ballerinalang.jvm.values.api.BXML xmlPayload)
xmlPayload - The xml BXML payload.public void setTextPayload(String textPayload)
textPayload - The text payload.public void setBinaryPayload(byte[] binaryPayload)
binaryPayload - The byte[] payload.public void setBodyParts(Entity[] bodyParts, String contentType)
bodyParts - The entities which make up the message bodycontentType - The content type of the top level message. Set this to override the default
`content-type` header value which is 'multipart/form-data'public void setByteChannel(org.ballerinalang.stdlib.io.channels.base.Channel byteChannel,
String contentType)
byteChannel - Channel Channel object which contains the payload data.contentType - The content type of the top level message. Set this to override the default
`content-type` header value which is 'application/octet-stream'public org.ballerinalang.jvm.values.ObjectValue getNativeRequestObject()
ObjectValue representing the request.public void setEntity(Entity entity)
public Entity getEntityWithoutBody()
public Entity getEntity()
Copyright © 2021 WSO2. All rights reserved.