Skip to main content

CreateHttpCommonRequestEvent

Overview

CreateHttpCommonRequestEvent This is an event that allows developers to send HTTP requests with various configurations, including authentication, custom headers, and SSL certificates. Please note that CreateHttpCommonRequestEvent cannot be used while a restart is in progress.


iOS/Swift

The Swift implementation is encapsulated within the KSMCreateHttpCommonRequestEvent class.

Initialization

    let event = KSMCreateHttpCommonRequestEvent(
fullUrl: String,
httpMethod: KSMCreateHttpCommonRequestHttpMethod,
content: String,
contentType: String,
userName: String,
password: String,
certificate: Data,
httpHeaders: [AnyHashable : Any]
)

let event = KSMCreateHttpCommonRequestEvent(
fullUrl: String,
httpMethod: KSMCreateHttpCommonRequestHttpMethod,
multiPartContent: [KsHttpMultiPart],
contentType: String,
userName: String,
password: String,
certificate: Data,
httpHeaders: [AnyHashable : Any]
)

let event = KSMCreateHttpCommonRequestEvent(
fullUrl: String,
httpMethod: KSMCreateHttpCommonRequestHttpMethod,
content: String,
contentType: String,
userName: String,
password: String,
certificate: Data,
httpHeaders: [AnyHashable : Any],
cookieIdentifier: String
)

let event = KSMCreateHttpCommonRequestEvent(
fullUrl: String,
httpMethod: KSMCreateHttpCommonRequestHttpMethod,
content: String,
contentType: String,
userName: String,
password: String,
certificate: Data,
timeout: UnsafeMutablePointer<UInt>,
isRetry: UnsafeMutablePointer<ObjCBool>,
httpHeaders: [AnyHashable : Any]
)

let event = KSMCreateHttpCommonRequestEvent(
fullUrl: String,
httpMethod: KSMCreateHttpCommonRequestHttpMethod,
multiPartContent: [KsHttpMultiPart],
contentType: String,
userName: String,
password: String,
certificate: Data,
httpHeaders: [AnyHashable : Any],
cookieIdentifier: String
)

let event = KSMCreateHttpCommonRequestEvent(
followRedirect: Bool,
fullUrl: String,
httpMethod: KSMCreateHttpCommonRequestHttpMethod,
content: String,
contentType: String,
userName: String,
password: String,
certificate: Data,
httpHeaders: [AnyHashable : Any],
cookieIdentifier: String
)

let event = KSMCreateHttpCommonRequestEvent(
fullUrl: String,
httpMethod: KSMCreateHttpCommonRequestHttpMethod,
content: String,
contentType: String,
userName: String,
password: String,
certificate: Data,
timeout: UnsafeMutablePointer<UInt>,
isRetry: UnsafeMutablePointer<ObjCBool>,
httpHeaders: [AnyHashable : Any],
cookieIdentifier: String
)

let event = KSMCreateHttpCommonRequestEvent(
fullUrl: String,
httpMethod: KSMCreateHttpCommonRequestHttpMethod,
content: String,
contentType: String,
userName: String,
password: String,
certificate: Data,
httpHeaders: [AnyHashable : Any],
cookieIdentifier: String,
accessTokenIdentifier: String
)

let event = KSMCreateHttpCommonRequestEvent(
followRedirect: Bool,
fullUrl: String,
httpMethod: KSMCreateHttpCommonRequestHttpMethod,
multiPartContent: [KsHttpMultiPart],
contentType: String,
userName: String,
password: String,
certificate: Data,
httpHeaders: [AnyHashable : Any],
cookieIdentifier: String
)

let event = KSMCreateHttpCommonRequestEvent(
fullUrl: String,
httpMethod: KSMCreateHttpCommonRequestHttpMethod,
multiPartContent: [KsHttpMultiPart],
contentType: String,
userName: String,
password: String,
certificate: Data,
httpHeaders: [AnyHashable : Any],
cookieIdentifier: String,
accessTokenIdentifier: String
)

let event = KSMCreateHttpCommonRequestEvent(
followRedirect: Bool,
fullUrl: String,
httpMethod: KSMCreateHttpCommonRequestHttpMethod,
content: String,
contentType: String,
userName: String,
password: String,
certificate: Data,
timeout: UnsafeMutablePointer<UInt>,
isRetry: UnsafeMutablePointer<ObjCBool>,
httpHeaders: [AnyHashable : Any],
cookieIdentifier: String
)

let event = KSMCreateHttpCommonRequestEvent(
fullUrl: String,
httpMethod: KSMCreateHttpCommonRequestHttpMethod,
content: String,
contentType: String,
userName: String,
password: String,
certificate: Data,
timeout: UnsafeMutablePointer<UInt>,
isRetry: UnsafeMutablePointer<ObjCBool>,
httpHeaders: [AnyHashable : Any],
cookieIdentifier: String,
accessTokenIdentifier: String
)
enum KSMCreateHttpCommonRequestHttpMethod: Int {
case get
case post
case put
case delete
}

Properties

PropertyTypeDescription
fullUrlString*Absolute URL of the request
httpMethodKSMCreateHttpCommonRequestHttpMethodHTTP method (GET, POST, etc.)
contentString*Request body content
contentTypeString*MIME type of the content
userNameString*Username for authentication
passwordString*Password for authentication
certificateData*SSL certificate chain in PEM format
httpHeaders[AnyHashable : Any]*Additional HTTP headers
cookieIdentifierString*Cookie identifier
followRedirectBoolWhether the request follows redirects
timeoutUnsafeMutablePointer<UInt>Timeout duration for the request in seconds
isRetryUnsafeMutablePointer<ObjCBool>Specifies if the request is a retry

Response Handling

The response is handled by KSMCreateHttpCommonRequestResultEvent:

- (instancetype _Nonnull) initWithStatus:(KSMCreateHttpCommonRequestStatus)status
httpStatus:(int)httpStatus
response:(NSData* _Nonnull)response
responseHeaders:(NSDictionary *_Nonnull)responseHeaders NS_DESIGNATED_INITIALIZER;

Example Response Handling:

if resultEvent.status == .success {
print("Response: " + (String(bytes: resultEvent.response, encoding: .utf8) ?? ""))
} else {
print("Error: \(resultEvent.status)")
}

Android/Kotlin

The Kotlin implementation is encapsulated in the CreateHttpCommonRequestEvent class.

Initialization

    val httpCommonReqEvent = CreateHttpCommonRequestEvent(
String fullUrl,
HttpMethod method,
String content,
String contentType,
String userName,
String password,
byte[] certificateChain
)

val httpCommonReqEvent = CreateHttpCommonRequestEvent(
String fullUrl,
HttpMethod method,
String content,
String contentType,
String userName,
String password,
byte[] certificateChain,
Map<String, String> additionalHeaders
)

val httpCommonReqEvent = CreateHttpCommonRequestEvent(
String fullUrl,
HttpMethod method,
String content,
String contentType,
String userName,
String password,
byte[] certificateChain,
Map<String, String> additionalHeaders,
String cookieIdentifier
)

val httpCommonReqEvent = CreateHttpCommonRequestEvent(
String fullUrl,
HttpMethod method,
String content,
String contentType,
String userName,
String password,
byte[] certificateChain,
Map<String, String> additionalHeaders,
String cookieIdentifier,
boolean followRedirect
)

val httpCommonReqEvent = CreateHttpCommonRequestEvent(
String fullUrl,
HttpMethod method,
String content,
String contentType,
String userName,
String password,
byte[] certificateChain,
Map<String, String> additionalHeaders,
String cookieIdentifier,
boolean followRedirect,
String accessTokenIdentifier
)

val httpCommonReqEvent = CreateHttpCommonRequestEvent(
String fullUrl,
HttpMethod method,
String content,
String contentType,
String userName,
String password,
byte[] certificateChain,
Map<String, String> additionalHeaders,
String cookieIdentifier,
boolean followRedirect,
String accessTokenIdentifier,
int timeout,
boolean isRetry
)

val httpCommonReqEvent = CreateHttpCommonRequestEvent(
String fullUrl,
HttpMethod method,
List<HttpMultiPart> multiPartContent,
String contentType,
String userName,
String password,
byte[] certificateChain
)

val httpCommonReqEvent = CreateHttpCommonRequestEvent(
String fullUrl,
HttpMethod method,
List<HttpMultiPart> multiPartContent,
String contentType,
String userName,
String password,
byte[] certificateChain,
Map<String, String> additionalHeaders
)

val httpCommonReqEvent = CreateHttpCommonRequestEvent(
String fullUrl,
HttpMethod method,
List<HttpMultiPart> multiPartContent,
String contentType,
String userName,
String password,
byte[] certificateChain,
Map<String, String> additionalHeaders,
String cookieIdentifier
)

val httpCommonReqEvent = CreateHttpCommonRequestEvent(
String fullUrl,
HttpMethod method,
List<HttpMultiPart> multiPartContent,
String contentType,
String userName,
String password,
byte[] certificateChain,
Map<String, String> additionalHeaders,
String cookieIdentifier,
boolean followRedirect
)

val httpCommonReqEvent = CreateHttpCommonRequestEvent(
String fullUrl,
HttpMethod method,
List<HttpMultiPart> multiPartContent,
String contentType,
String userName,
String password,
byte[] certificateChain,
Map<String, String> additionalHeaders,
String cookieIdentifier,
boolean followRedirect,
String accessTokenIdentifier
)

val httpCommonReqEvent = CreateHttpCommonRequestEvent(
String fullUrl,
HttpMethod method,
List<HttpMultiPart> multiPartContent,
String contentType,
String userName,
String password,
byte[] certificateChain,
Map<String, String> additionalHeaders,
String cookieIdentifier,
boolean followRedirect,
String accessTokenIdentifier,
int timeout,
boolean isRetry
)

	public enum HttpMethod {
GET, POST, PUT, DELETE
}

Properties

PropertyTypeDescription
fullUrlStringAbsolute URL of the request
methodHttpMethodHTTP method (GET, POST, etc.)
contentStringRequest body content
contentTypeStringMIME type of the content
userNameStringUsername for authentication
passwordStringPassword for authentication
certificateChainbyte[]SSL certificate chain in PEM format
additionalHeadersMap<String, String>Additional HTTP headers
cookieIdentifierStringCookie identifier
followRedirectbooleanWhether the request follows redirects
timeoutintTimeout duration for the request
isRetrybooleanSpecifies if the request is a retry

Response Handling

A corresponding response class CreateHttpCommonRequestResultEvent captures the HTTP response:

public CreateHttpCommonRequestResultEvent(int status, int httpStatus, byte[] response, Map<String, String> responseHeaders) {
this.status = status;
this.httpStatus = httpStatus;
this.response = response;
this.responseHeaders = responseHeaders;
}

Example Response Handling:

if (response.getHttpStatus == CreateHttpCommonRequestResultEvent.Status.success) {
System.out.println("Response: " + new String(response.getResponse()));
} else {
System.out.println("Error: " + response.getHttpStatus());
}