Tizen Native API  5.0
HTTP Session

The HTTP Session API provides functions for managing HTTP session.

Required Header

#include <http.h>

Overview

The HTTP Session API provides functions for managing HTTP session. Using the HTTP Session, you can implement features that allow the users of your application to:

  • Create / Delete HTTP session
  • Get activated transaction count
  • Manage redirection

Related Features

This API is related with the following features:

  • http://tizen.org/feature/network.internet
    It is recommended to design feature related codes in your application for reliability.
    You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
    To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
    More details on featuring your application can be found from Feature Element.

Functions

int http_session_create (http_session_mode_e mode, http_session_h *http_session)
 Creates the HTTP session handle.
int http_session_destroy (http_session_h http_session)
 Destroys the HTTP session handle.
int http_session_open_transaction (http_session_h http_session, http_method_e method, http_transaction_h *http_transaction)
 Opens HTTP transaction from the HTTP Session.
int http_session_set_auto_redirection (http_session_h http_session, bool auto_redirection)
 Sets the value to redirect the HTTP request automatically.
int http_session_get_auto_redirection (http_session_h http_session, bool *auto_redirect)
 Gets the auto redirection for the HTTP request.
int http_session_get_active_transaction_count (http_session_h http_session, int *active_transaction_count)
 Gets the number of active transactions in the current session.
int http_session_get_max_transaction_count (http_session_h http_session, int *transaction_count)
 Gets the maximum number of transactions for the current session.
int http_session_destroy_all_transactions (http_session_h http_session)
 Destroys all transactions.

Enumeration Type Documentation

Enumeration for the HTTP session.

Since :
3.0
Enumerator:
HTTP_SESSION_MODE_NORMAL 

The Normal Mode

HTTP_SESSION_MODE_PIPELINING 

The Pipelining mode


Function Documentation

int http_session_create ( http_session_mode_e  mode,
http_session_h http_session 
)

Creates the HTTP session handle.

Since :
3.0
Remarks:
The http_session should be released using http_session_destroy(). Opened transactions can't be submitted after destroying session handle.
Parameters:
[in]modeThe HTTP session mode
[out]http_sessionThe HTTP session handle
Returns:
0 on success, otherwise negative error value
Return values:
HTTP_ERROR_NONESuccessful
HTTP_ERROR_INVALID_PARAMETERInvalid parameter
HTTP_ERROR_INVALID_OPERATIONInvalid operation
HTTP_ERROR_OUT_OF_MEMORYOut of memory
HTTP_ERROR_NOT_SUPPORTEDNot Supported
See also:
http_session_destroy()
int http_session_destroy ( http_session_h  http_session)

Destroys the HTTP session handle.

Since :
3.0
Remarks:
http_session should be set to NULL after using it
Parameters:
[in]http_sessionThe HTTP session handle
Returns:
0 on success, otherwise negative error value
Return values:
HTTP_ERROR_NONESuccessful
HTTP_ERROR_INVALID_PARAMETERInvalid parameter
HTTP_ERROR_INVALID_OPERATIONInvalid operation
HTTP_ERROR_NOT_SUPPORTEDNot Supported
See also:
http_session_create()

Destroys all transactions.

Since :
3.0
Remarks:
All http_transactions should be set to NULL after using it
Parameters:
[in]http_sessionThe HTTP session handle
Returns:
0 on success, otherwise negative error value
Return values:
HTTP_ERROR_NONESuccessful
HTTP_ERROR_INVALID_PARAMETERInvalid parameter
HTTP_ERROR_INVALID_OPERATIONInvalid operation
HTTP_ERROR_OPERATION_FAILEDOperation failed
HTTP_ERROR_NOT_SUPPORTEDNot Supported
int http_session_get_active_transaction_count ( http_session_h  http_session,
int *  active_transaction_count 
)

Gets the number of active transactions in the current session.

Since :
3.0
Parameters:
[in]http_sessionThe HTTP session handle
[out]active_transaction_countThe number of activated transactions
Returns:
0 on success, otherwise negative error value
Return values:
HTTP_ERROR_NONESuccessful
HTTP_ERROR_INVALID_PARAMETERInvalid parameter
HTTP_ERROR_INVALID_OPERATIONInvalid operation
HTTP_ERROR_NOT_SUPPORTEDNot Supported
int http_session_get_auto_redirection ( http_session_h  http_session,
bool *  auto_redirect 
)

Gets the auto redirection for the HTTP request.

Since :
3.0
Parameters:
[in]http_sessionThe HTTP session handle
[out]auto_redirectThe value of auto redirect
Returns:
0 on success, otherwise negative error value
Return values:
HTTP_ERROR_NONESuccessful
HTTP_ERROR_INVALID_PARAMETERInvalid parameter
HTTP_ERROR_INVALID_OPERATIONInvalid operation
HTTP_ERROR_NOT_SUPPORTEDNot Supported
See also:
http_session_set_auto_redirection()
int http_session_get_max_transaction_count ( http_session_h  http_session,
int *  transaction_count 
)

Gets the maximum number of transactions for the current session.

Since :
3.0
Parameters:
[in]http_sessionThe HTTP session handle
[out]transaction_countThe maximum transaction count
Returns:
0 on success, otherwise negative error value
Return values:
HTTP_ERROR_NONESuccessful
HTTP_ERROR_INVALID_PARAMETERInvalid parameter
HTTP_ERROR_INVALID_OPERATIONInvalid operation
HTTP_ERROR_NOT_SUPPORTEDNot Supported
int http_session_open_transaction ( http_session_h  http_session,
http_method_e  method,
http_transaction_h http_transaction 
)

Opens HTTP transaction from the HTTP Session.

Since :
3.0
Remarks:
The http_transaction should be released using http_transaction_destroy().
Parameters:
[in]http_sessionThe HTTP session handle
[in]methodThe HTTP request method
[out]http_transactionThe HTTP transaction handle
Returns:
0 on success, otherwise negative error value
Return values:
HTTP_ERROR_NONESuccessful
HTTP_ERROR_INVALID_PARAMETERInvalid parameter
HTTP_ERROR_INVALID_OPERATIONInvalid operation
HTTP_ERROR_OUT_OF_MEMORYOut of memory
HTTP_ERROR_NOT_SUPPORTEDNot Supported
int http_session_set_auto_redirection ( http_session_h  http_session,
bool  auto_redirection 
)

Sets the value to redirect the HTTP request automatically.

Since :
3.0
Parameters:
[in]http_sessionThe HTTP session handle
[in]auto_redirectionThe value which determines whether allow redirection or not
Returns:
0 on success, otherwise negative error value
Return values:
HTTP_ERROR_NONESuccessful
HTTP_ERROR_INVALID_PARAMETERInvalid parameter
HTTP_ERROR_INVALID_OPERATIONInvalid operation
HTTP_ERROR_NOT_SUPPORTEDNot Supported
See also:
http_session_get_auto_redirection()