extern "C" {
#endif
+#ifndef TIZEN_ERROR_HTTP
+#define TIZEN_ERROR_HTTP -0x03000000
+#endif
+
/**
* @file http.h
*/
/**
- * @addtogroup CAPI_NETWORK_HTTP_MANAGER_MODULE
+ * @addtogroup CAPI_NETWORK_HTTP_MODULE
* @{
*/
/**
- * @brief The Http handle.
+ * @brief The HTTP Session handle.
* @since_tizen 3.0
*/
typedef void * http_session_h;
+
+/**
+ * @brief The HTTP Transaction handle.
+ * @since_tizen 3.0
+ */
typedef void * http_transaction_h;
/**
*/
/**
- * @internal
+ * @addtogroup CAPI_NETWORK_HTTP_SESSION_MODULE
+ * @{
+ */
+
+/**
* @brief Enumeration for the http session.
* @since_tizen 3.0
*/
} http_session_mode_e;
/**
- * @internal
+ * @}
+ */
+
+/**
+* @addtogroup CAPI_NETWORK_HTTP_MODULE
+* @{
+*/
+
+/**
* @brief Enumeration for the http method.
* @since_tizen 3.0
*/
typedef enum {
- HTTP_METHOD_NONE = 0x0,
HTTP_METHOD_GET = 0x40, /**< The HTTP GET Method */
HTTP_METHOD_OPTIONS = 0x41, /**< The HTTP OPTIONS Method */
HTTP_METHOD_HEAD = 0x42, /**< The HTTP HEAD Method */
} http_method_e;
/**
- * @internal
* @brief Enumeration for the http version.
* @since_tizen 3.0
*/
typedef enum {
- HTTP_VERSION_1_0, /**< %Http version 1.0 */
- HTTP_VERSION_1_1 /**< %Http version 1.1 */
+ HTTP_VERSION_1_0, /**< HTTP version 1.0 */
+ HTTP_VERSION_1_1 /**< HTTP version 1.1 */
} http_version_e;
/**
- * @internal
* @brief Enumeration for transfer pause state
* @since_tizen 3.0
*/
typedef enum {
HTTP_PAUSE_RECV = 1 << 0, /**< Pause receiving data */
HTTP_PAUSE_SEND = 1 << 2, /**< Pause sending data */
- HTTP_PAUSE_ALL = HTTP_PAUSE_RECV | HTTP_PAUSE_SEND /**< %Pause both directions */
-} http_pause_state_e;
+ HTTP_PAUSE_ALL = HTTP_PAUSE_RECV | HTTP_PAUSE_SEND /**< Pause both directions */
+} http_pause_type_e;
/**
- * @internal
* @brief Enumeration for the http error code.
* @since_tizen 3.0
*/
typedef enum {
- HTTP_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
- HTTP_ERROR_NOT_PERMITTED = TIZEN_ERROR_NOT_PERMITTED, /**< Operation not permitted */
- HTTP_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- HTTP_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- HTTP_ERROR_RESOURCE_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Resource busy */
- HTTP_ERROR_NOT_ENABLED = 0x0501, /**< Not enabled */
- HTTP_ERROR_OPERATION_FAILED = 0x0502, /**< Operation failed */
- HTTP_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
- HTTP_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< API is not supported */
- HTTP_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ HTTP_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ HTTP_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ HTTP_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ HTTP_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ HTTP_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
+ HTTP_ERROR_OPERATION_FAILED = TIZEN_ERROR_HTTP|0x01, /**< Operation failed */
+ HTTP_ERROR_COULDNT_RESOLVE_HOST = TIZEN_ERROR_HTTP|0x06, /**< Couldn't resolve host */
+ HTTP_ERROR_COULDNT_CONNECT = TIZEN_ERROR_HTTP|0x07, /**< Couldn't Connect to host */
+ HTTP_ERROR_OPERATION_TIMEDOUT = TIZEN_ERROR_HTTP|0x28, /**< Timeout */
+ HTTP_ERROR_SSL_CONNECT_ERROR = TIZEN_ERROR_HTTP|0x35, /**< SSL Error */
+ HTTP_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< API is not supported */
} http_error_code_e;
/**
- * @internal
* @brief Enumeration for the http status code.
* @since_tizen 3.0
*/
} http_status_code_e;
/**
- * @internal
* @brief Called when the http header is received.
* @since_tizen 3.0
- * @details Called when the http header is received.
- * @param[in] header header information of Http Transaction
- * @param[in] header_len length of the Http Transaction header
+ * @param[in] http_transaction The http transaction handle
+ * @param[in] header The header information of Http Transaction
+ * @param[in] header_len The length of the Http Transaction header
+ * @param[in] user_data The user data
+ * @see http_transaction_set_received_header_cb()
*/
-typedef void (*http_transaction_header_cb)(http_transaction_h transaction, char *header, size_t header_len, void *user_data);
+typedef void (*http_transaction_header_cb)(http_transaction_h http_transaction, char *header, size_t header_len, void *user_data);
/**
- * @internal
* @brief Called when the http response is received.
* @since_tizen 3.0
- * @details Called when the http response is received.
- * @param[in] body response information of Http Transaction
- * @param[in] size Size in bytes of each element to be written
- * @param[in] count Number of elements, each one with a size of size bytes
+ * @param[in] http_transaction The http transaction handle
+ * @param[in] body Response information of Http Transaction
+ * @param[in] size Size in bytes of each element to be written
+ * @param[in] count Number of elements, each one with a size of size bytes
+ * @param[in] user_data The user data
+ * @see http_transaction_set_received_body_cb()
*/
-typedef void (*http_transaction_body_cb)(http_transaction_h transaction, char *body, size_t size, size_t count, void *user_data);
+typedef void (*http_transaction_body_cb)(http_transaction_h http_transaction, char *body, size_t size, size_t count, void *user_data);
/**
- * @internal
* @brief Called when the http ready to write event is received.
* @since_tizen 3.0
- * @details Called when the http ready to write event is received.
- * @param[in] recommended_chunk_size recommended chunk length of the Http transaction
+ * @param[in] http_transaction The http transaction handle
+ * @param[in] recommended_chunk_size Recommended chunk length(bytes) of the Http transaction
+ * @param[in] user_data The user data
+ * @see http_transaction_set_uploaded_cb()
*/
-typedef void (*http_transaction_write_cb)(http_transaction_h transaction, int recommended_chunk_size, void *user_data);
+typedef void (*http_transaction_write_cb)(http_transaction_h http_transaction, int recommended_chunk_size, void *user_data);
/**
- * @internal
* @brief Called when the http transaction is completed.
* @since_tizen 3.0
- * @details Called when the http transaction is completed.
+ * @param[in] http_transaction The http transaction handle
+ * @param[in] user_data The user data
+ * @see http_transaction_set_completed_cb()
*/
-typedef void (*http_transaction_completed_cb)(http_transaction_h transaction, void *user_data);
+typedef void (*http_transaction_completed_cb)(http_transaction_h http_transaction, void *user_data);
/**
- * @internal
* @brief Called when the http transaction is aborted.
+ * @details Following error codes can be delivered. \n
+ * #HTTP_ERROR_OPERATION_FAILED, \n
+ * #HTTP_ERROR_COULDNT_RESOLVE_HOST, \n
+ * #HTTP_ERROR_COULDNT_CONNECT, \n
+ * #HTTP_ERROR_OPERATION_TIMEDOUT, \n
+ * #HTTP_ERROR_SSL_CONNECT_ERROR
* @since_tizen 3.0
- * @details Called when the http transaction is aborted.
- * @param[in] reason aborted reason code
- */
-typedef void (*http_transaction_aborted_cb)(http_transaction_h transaction, int reason, void *user_data);
-
-/**
- * @internal
- * @brief Called to notify when the content body of the request message is being uploaded.
- * @since_tizen 3.0
- * @details Called to notify when the content body of the request message is being uploaded.
- * @param[in] currentLength current length of the uploaded data (in bytes)
- * @param[in] totalLength total length of the data (in bytes) to upload
+ * @param[in] http_transaction The http transaction handle
+ * @param[in] error The error code about aborted reason
+ * @param[in] user_data The user data
+ * @see http_transaction_set_aborted_cb()
*/
-typedef void (*http_transaction_upload_progress_cb)(long long currentLength, long long totalLength);
+typedef void (*http_transaction_aborted_cb)(http_transaction_h http_transaction, http_error_code_e error, void *user_data);
/**
- * @internal
- * @brief Called to notify when the content body of the response message is being downloaded.
+ * @brief Called to notify when the content body of the response message is being downloaded or uploaded.
* @since_tizen 3.0
- * @details Called to notify when the content body of the response message is being downloaded.
- * @param[in] currentLength current length of the downloaded data (in bytes)
- * @param[in] totalLength total length of the data (in bytes) to download
+ * @param[in] http_transaction The http transaction handle
+ * @param[in] download_total The total length of the data (in bytes) to download
+ * @param[in] download_now The current length of the downloaded data (in bytes)
+ * @param[in] upload_total The total length of the data (in bytes) to upload
+ * @param[in] upload_now The current length of the uploaded data (in bytes)
+ * @param[in] user_data The user data
+ * @see http_transaction_set_progress_cb()
*/
-typedef void (*http_transaction_download_progress_cb)(long long currentLength, long long totalLength);
+typedef void (*http_transaction_progress_cb)(http_transaction_h http_transaction, double download_total, double download_now, double upload_total, double upload_now, void *user_data);
/**
- * @internal
- * @addtogroup CAPI_NETWORK_HTTP_MODULE
- * @{
- */
-
-/**
- * @internal
- * @brief Initialize the Http module.
+ * @brief Initializes the Http module.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Initialize the Http module.
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/internet
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
- * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_OPERATION_FAILED Operation failed
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
+ * @retval #HTTP_ERROR_PERMISSION_DENIED Permission denied
+ * @see http_deinit()
*/
-int http_init();
+int http_init(void);
/**
- * @internal
- * @brief Deinitialize the Http module.
+ * @brief Deinitializes the Http module.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Deinitialize the Http module.
+ * @return 0 on success, otherwise negative error value
+ * @retval #HTTP_ERROR_NONE Successful
+ * @retval #HTTP_ERROR_OPERATION_FAILED Operation failed
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
+ * @see http_init()
*/
-void http_deinit();
+int http_deinit(void);
/**
* @}
*/
/**
- * @internal
* @addtogroup CAPI_NETWORK_HTTP_SESSION_MODULE
* @{
*/
/**
- * @internal
- * @brief Create the Http Session.
+ * @brief Creates the Http session handle.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Create the Http Session.
- * @param[out] http_session http session handle
- * @param[in] mode http session mode
+ * @remarks The @a http_session should be released using http_session_destroy().
+ * @param[in] mode The http session mode
+ * @param[out] http_session The http session handle
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
+ * @see http_session_destroy()
*/
-int http_create_session(http_session_h *http_session, http_session_mode_e mode);
+int http_session_create(http_session_mode_e mode, http_session_h *http_session);
/**
- * @internal
- * @brief Delete the Http Session.
+ * @brief Destroys the Http session handle.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Delete the Http Session.
- * @param[in] http_session http session handle
+ * @param[in] http_session The http session handle
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
+ * @see http_session_create()
*/
-int http_delete_session(http_session_h http_session);
+int http_session_destroy(http_session_h http_session);
+
+/**
+ * @brief Opens Http transaction from the Http Session.
+ * @since_tizen 3.0
+ * @remarks The @a http_transaction should be released using http_transaction_destroy().
+ * @param[in] http_session The http session handle
+ * @param[in] method The http request method
+ * @param[out] http_transaction The http transaction handle
+ * @return 0 on success, otherwise negative error value
+ * @retval #HTTP_ERROR_NONE Successful
+ * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
+ */
+int http_session_open_transaction(http_session_h http_session, http_method_e method, http_transaction_h *http_transaction);
/**
- * @internal
* @brief Sets the value to redirect the HTTP request automatically.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Sets the value to redirect the HTTP request automatically.
- * @param[in] http_session http session handle
- * @param[in] auto_redirect set value of auto redirect
+ * @param[in] http_session The http session handle
+ * @param[in] auto_redirection The value which determines whether allow redirection or not
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
+ * @see http_session_get_auto_redirection()
*/
-int http_session_set_auto_redirection(http_session_h http_session, bool enable);
+int http_session_set_auto_redirection(http_session_h http_session, bool auto_redirection);
/**
- * @internal
- * @brief Get the auto redirection for the HTTP request.
+ * @brief Gets the auto redirection for the HTTP request.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Get the auto redirection for the HTTP request.
- * @param[in] http_session http session handle
- * @param[out] auto_redirect get value of auto redirect
+ * @param[in] http_session The http session handle
+ * @param[out] auto_redirect The value of auto redirect
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
+ * @see http_session_set_auto_redirection()
*/
int http_session_get_auto_redirection(http_session_h http_session, bool *auto_redirect);
/**
- * @internal
* @brief Gets the number of active transactions in the current session.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Gets the number of active transactions in the current session.
- * @param[in] http_session http session handle
- * @param[out] active_transaction_count active transaction count
+ * @param[in] http_session The http session handle
+ * @param[out] active_transaction_count The number of activated transactions
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
int http_session_get_active_transaction_count(http_session_h http_session, int *active_transaction_count);
/**
- * @internal
* @brief Gets the maximum number of transactions for the current session.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Gets the maximum number of transactions for the current session.
- * @param[in] http_session http session handle
- * @param[out] transaction_count maximum transaction count
+ * @param[in] http_session The http session handle
+ * @param[out] transaction_count The maximum transaction count
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
int http_session_get_max_transaction_count(http_session_h http_session, int *transaction_count);
+
+/*
+ * @brief Destroys all transaction.
+ * @since_tizen 3.0
+ * @param[in] http_session The http session handle
+ * @return 0 on success, otherwise negative error value
+ * @retval #HTTP_ERROR_NONE Successful
+ * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_OPERATION_fAILED Operation failed
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
+ */
+int http_session_destroy_all_transactions(http_session_h http_session);
/**
* @}
*/
/**
- * @internal
* @addtogroup CAPI_NETWORK_HTTP_TRANSACTION_MODULE
* @{
*/
/**
- * @internal
- * @brief Open Http Transaction from the Http Session.
+ * @brief Submits the Http request.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Open Http Transaction from the Http Session.
- * @param[in] http_session http session handle
- * @param[in] method http method
- * @param[in] transaction_header_callback Header callback
- * @param[in] transaction_body_callback Body callback
- * @param[in] transaction_write_callback write callback
- * @param[in] transaction_completed_cb completed callback
- * @param[in] transaction_aborted_cb aborted callback
- * @param[out] http_transaction http transaction handle
+ * @param[in] http_transaction The http transaction handle
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_open_transaction(http_session_h http_session, http_method_e method, http_transaction_h *http_transaction);
+int http_transaction_submit(http_transaction_h http_transaction);
/**
- * @internal
- * @brief Submit the Http request.
+ * @brief Closes the http transaction handle.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Submit the Http request.
+ * @remarks The @a transaction is released by http_transaction_destroy().
+ * It should be used after finishing http trasaction.
* @param[in] http_transaction The http transaction handle
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
+ * @see http_transaction_create()
*/
-int http_transaction_submit(http_transaction_h http_transaction);
+int http_transaction_destroy(http_transaction_h http_transaction);
-/**
- * @internal
- * @brief Close the Http Transaction.
+/*
+ * @brief Registers callback called when receive header.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Close the Http Transaction.
* @param[in] http_transaction The http transaction handle
+ * @param[in] header_cb The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_transaction_close(http_transaction_h http_transaction);
-
-int http_transaction_set_received_header_cb(http_transaction_h transaction, http_transaction_header_cb header_cb, void* user_data);
-
-int http_transaction_set_received_body_cb(http_transaction_h transaction, http_transaction_body_cb body_cb, void* user_data);
+int http_transaction_set_received_header_cb(http_transaction_h http_transaction, http_transaction_header_cb header_cb, void* user_data);
-int http_transaction_set_uploaded_cb(http_transaction_h transaction, http_transaction_write_cb write_cb, void* user_data);
-
-int http_transaction_set_completed_cb(http_transaction_h transaction, http_transaction_completed_cb completed_cb, void* user_data);
-
-int http_transaction_set_aborted_cb(http_transaction_h http_transaction, http_transaction_aborted_cb aborted_cb, void* user_data);
-
-int http_transaction_close_all(http_session_h session);
+/*
+ * @brief Registers callback called when receive body.
+ * @since_tizen 3.0
+ * @param[in] http_transaction The http transaction handle
+ * @param[in] body_cb The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return 0 on success, otherwise negative error value
+ * @retval #HTTP_ERROR_NONE Successful
+ * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
+ */
+int http_transaction_set_received_body_cb(http_transaction_h http_transaction, http_transaction_body_cb body_cb, void* user_data);
+/*
+ * @brief Registers callback called when write data.
+ * @since_tizen 3.0
+ * @param[in] http_transaction The http transaction handle
+ * @param[in] write_cb The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return 0 on success, otherwise negative error value
+ * @retval #HTTP_ERROR_NONE Successful
+ * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
+ */
+int http_transaction_set_uploaded_cb(http_transaction_h http_transaction, http_transaction_write_cb write_cb, void* user_data);
-/**
- * @internal
- * @brief Sets the progress callbacks.
+/*
+ * @brief Registers callback called when transaction is completed.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Sets the progress callbacks.
* @param[in] http_transaction The http transaction handle
- * @param[in] upload_progress_cb upload callback
- * @param[in] download_progress_cb download callback
+ * @param[in] completed_cb The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_transaction_set_progress_cb(http_transaction_h http_transaction, http_transaction_upload_progress_cb upload_progress_cb,
- http_transaction_download_progress_cb download_progress_cb);
+int http_transaction_set_completed_cb(http_transaction_h http_transaction, http_transaction_completed_cb completed_cb, void* user_data);
-/**
- * @internal
- * @brief Sets the timeout in seconds that is the timeout for waiting the transaction. @n
- * A timeout value of zero means an infinite timeout.
+/*
+ * @brief Registers callback called when transaction is aborted.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Sets the timeout in seconds that is the timeout for waiting the transaction.
* @param[in] http_transaction The http transaction handle
- * @param[in] timeout timeout in seconds
+ * @param[in] header_cb The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_transaction_set_timeout(http_transaction_h http_transaction, int timeout);
+int http_transaction_set_aborted_cb(http_transaction_h http_http_transaction, http_transaction_aborted_cb aborted_cb, void* user_data);
+
/**
- * @internal
- * @brief Get the time out in seconds for the transaction.
+ * @brief Registers the progress callbacks.
+ * @details Registers callback that is called when data is uploaded/downloaded.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Get the time out in seconds for the transaction.
* @param[in] http_transaction The http transaction handle
- * @param[out] timeout timeout in seconds
+ * @param[in] progress_cb The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_transaction_get_timeout(http_transaction_h http_transaction, int *timeout);
+int http_transaction_set_progress_cb(http_transaction_h http_transaction, http_transaction_progress_cb progress_cb, void* user_data);
/**
- * @internal
- * @brief Sets a user object to the instance of HTTP transaction.
+ * @brief Sets the timeout in seconds that is the timeout for waiting the transaction.
+ * @details Sets the timeout in seconds that is the timeout for waiting the transaction. \n
+ * A timeout value of zero means an infinite timeout.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Sets a user object to the instance of HTTP transaction.
* @param[in] http_transaction The http transaction handle
- * @param[in] user_object user object
+ * @param[in] timeout The timeout in seconds
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_transaction_set_user_object(http_transaction_h http_transaction, void *user_object);
+int http_transaction_set_timeout(http_transaction_h http_transaction, int timeout);
/**
- * @internal
- * @brief Gets a user object that is set to the instance of HTTP transaction.
+ * @brief Gets the time out in seconds for the transaction.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Gets a user object that is set to the instance of HTTP transaction.
* @param[in] http_transaction The http transaction handle
- * @param[out] user_object user object
+ * @param[out] timeout The timeout in seconds
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_transaction_get_user_object(http_transaction_h http_transaction, void **user_object);
+int http_transaction_get_timeout(http_transaction_h http_transaction, int *timeout);
/**
- * @internal
- * @brief Resumes the transaction after the http_transaction_cert_verifcation_required_cb event is invoked.
+ * @brief Resumes the transaction.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Resumes the transaction after the http_transaction_cert_verifcation_required_cb event is invoked.
* @param[in] http_transaction The http transaction handle
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_OPERATION_FAILED Operation failed
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
int http_transaction_resume(http_transaction_h http_transaction);
/**
- * @internal
- * @brief Pauses the transaction after the http_transaction_cert_verifcation_required_cb event is invoked.
+ * @brief Pauses the transaction.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Pauses the transaction after the http_transaction_cert_verifcation_required_cb event is invoked.
* @param[in] http_transaction The http transaction handle
+ * @param[in] pause_type The pause type of the connection
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_OPERATION_FAILED Operation failed
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_transaction_pause(http_transaction_h http_transaction, http_pause_state_e pause_state);
+int http_transaction_pause(http_transaction_h http_transaction, http_pause_type_e pause_type);
/**
- * @internal
* @brief Sets ready to write event for a transaction.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Sets ready to write event for a transaction.
* @param[in] http_transaction The http transaction handle
- * @param[out] read_to_write enable/disable ready to write
+ * @param[out] read_to_write Enable/disable ready to write
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
int http_transaction_set_ready_to_write(http_transaction_h http_transaction, bool read_to_write);
/**
- * @internal
- * @brief Set the interface name.
+ * @brief Sets the interface name.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Set the interface name.
* @param[in] http_transaction The http transaction handle
- * @param[in] interface_name interface name
+ * @param[in] interface_name The interface name to use as outgoing network interface
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
int http_transaction_set_interface_name(http_transaction_h http_transaction, const char *interface_name);
/**
- * @internal
- * @brief Get the interface name.
+ * @brief Gets the interface name.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Get the interface name.
- * @param[in] http_transaction The http transaction handle
- * @param[out] interface_name interface name
+ * @remarks The @a interface_name should be freed using free().
+ * @param[in] http_transaction The http transaction handle
+ * @param[out] interface_name The interface name
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
int http_transaction_get_interface_name(http_transaction_h http_transaction, char **interface_name);
/**
- * @internal
* @brief Sets the flag to verify a server certificate.
+ * @details The verify determines whether verifies the peer's certificate.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Get the interface name.
* @param[in] http_transaction The http transaction handle
- * @param[in] verify flag to verify a server certificate.
+ * @param[in] verify The flag to verify a server certificate; true means verifies; false means it doesn't.
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
int http_transaction_set_server_certificate_verification(http_transaction_h http_transaction, bool verify);
/**
- * @internal
* @brief Gets the flag to verify a server certificate.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Get the interface name.
* @param[in] http_transaction The http transaction handle
- * @param[out] verify flag to verify a server certificate.
+ * @param[out] verify The flag to verify a server certificate; true means verifies; false means it doesn't.
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
int http_transaction_get_server_certificate_verification(http_transaction_h http_transaction, bool* verify);
/**
- * @internal
- * @brief Adds a named field, which is a <@c fieldName, @c fieldValue> pair, to the current instance of Http Transaction.
- * @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
+ * @brief Adds a named field to header.
* @details Adds a named field, which is a <@c fieldName, @c fieldValue> pair, to the current instance of Http Transaction.
+ * @since_tizen 3.0
* @param[in] http_transaction The http transaction handle
- * @param[in] field_name Http Header Field name
- * @param[in] field_name Http Header Field value
+ * @param[in] field_name The http Header Field name
+ * @param[in] field_value The http Header Field value
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_header_add_field(http_transaction_h http_transaction, const char *field_name, const char* field_value);
+int http_transaction_header_add_field(http_transaction_h http_transaction, const char *field_name, const char* field_value);
/**
- * @internal
- * @brief Remove the named field, which is a <@c fieldName, @c fieldValue> pair, from the current instance of Http Transaction.
- * @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
+ * @brief Removes the named field from header.
* @details Remove the named field, which is a <@c fieldName, @c fieldValue> pair, from the current instance of Http Transaction.
+ * @since_tizen 3.0
* @param[in] http_transaction The http transaction handle
- * @param[in] field_name Http Header Field name
+ * @param[in] field_name The http Header Field name
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_header_remove_field(http_transaction_h http_transaction, const char *field_name);
+int http_transaction_header_remove_field(http_transaction_h http_transaction, const char *field_name);
/**
- * @internal
- * @brief Get the Http Header Field value.
+ * @brief Gets the Http Header Field value from custom header.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Get the Http Header Field value.
+ * @remarks The @a field_value should be freed using free().
* @param[in] http_transaction The http transaction handle
- * @param[in] field_name Http Header Field name
- * @param[out] field_value Http Header Field value
+ * @param[in] field_name The http Header Field name
+ * @param[out] field_value The http Header Field value
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_header_get_field_value(http_transaction_h http_transaction, const char *field_name, char **field_value);
+int http_transaction_header_get_field_value(http_transaction_h http_transaction, const char *field_name, char **field_value);
/**
* @}
*/
/**
- * @internal
* @addtogroup CAPI_NETWORK_HTTP_REQUEST_MODULE
* @{
*/
/**
- * @internal
* @brief Sets an HTTP method of the request header.
+ * @details Set an HTTP method such as GET, POST, PUT and etc.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Sets an HTTP method of the request header.
+ * @remarks The default method is GET.
* @param[in] http_transaction The http transaction handle
+ * @param[in] method The http method
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_request_set_method(http_transaction_h http_transaction, http_method_e method);
+int http_transaction_request_set_method(http_transaction_h http_transaction, http_method_e method);
/**
- * @internal
- * @brief Get the Http method.
+ * @brief Gets the Http method from request header.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Get the Http method.
* @param[in] http_transaction The http transaction handle
- * @param[out] method method
+ * @param[out] method The http method
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_request_get_method(http_transaction_h http_transaction, http_method_e *method);
+int http_transaction_request_get_method(http_transaction_h http_transaction, http_method_e *method);
/**
- * @internal
* @brief Sets an HTTP version of the request header.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Sets an HTTP version of the request header.
- * @param[in] http_transaction The http transaction handle
+ * @remarks The default version is HTTP 1.1.
+ * @param[in] http_transaction The http transaction handle
+ * @param[in] version The http version
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_request_set_version(http_transaction_h http_transaction, http_version_e version);
+int http_transaction_request_set_version(http_transaction_h http_transaction, http_version_e version);
/**
- * @internal
- * @brief Get the Http version.
- * @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
+ * @brief Gets the Http version from request header.
* @details Get the Http version.
- * @param[in] http_transaction The http transaction handle
- * @param[out] version version
+ * @since_tizen 3.0
+ * @param[in] http_transaction The http transaction handle
+ * @param[out] version The http version
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_request_get_version(http_transaction_h http_transaction, http_version_e *version);
+int http_transaction_request_get_version(http_transaction_h http_transaction, http_version_e *version);
/**
- * @internal
* @brief Sets a URI of the request header.
- * @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
* @details Sets a URI of the request header.
- * @param[in] http_transaction The http transaction handle
+ * @since_tizen 3.0
+ * @remarks It should be used before http_transaction_submit().
+ * @param[in] http_transaction The http transaction handle
+ * @param[in] host_uri The uri to use in the request
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_request_set_uri(http_transaction_h http_transaction, const char *host_uri);
+int http_transaction_request_set_uri(http_transaction_h http_transaction, const char *host_uri);
/**
- * @internal
- * @brief Get the uri.
+ * @brief Gets the uri.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Get the uri.
- * @param[in] http_transaction The http transaction handle
- * @param[out] host_uri host uri
+ * @remarks The @a host_uri should be freed using free().
+ * @param[in] http_transaction The http transaction handle
+ * @param[out] host_uri The host uri
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_request_get_uri(http_transaction_h http_transaction, char **host_uri);
+int http_transaction_request_get_uri(http_transaction_h http_transaction, char **host_uri);
/**
- * @internal
* @brief Sets the Accept-Encoding header field of HttpRequest.
+ * @details The Accept-Encoding header enables automatic decompression of HTTP downloads.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Sets the Accept-Encoding header field of HttpRequest.
- * @param[in] http_transaction The http transaction handle
- * @param[in] encoding encoding
+ * @remarks If empty string is set, an Accept-Encoding header contains all supported built-in compressions.
+ * @param[in] http_transaction The http transaction handle
+ * @param[in] encoding The encoding algorithms (e.g. gizp, deflate)
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_request_set_accept_encoding(http_transaction_h http_transaction, const char *encoding);
+int http_transaction_request_set_accept_encoding(http_transaction_h http_transaction, const char *encoding);
/**
- * @internal
- * @brief Get the Accept-Encoding header field of HttpRequest.
+ * @brief Gets the Accept-Encoding header field of HttpRequest.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Get the Accept-Encoding header field of HttpRequest.
- * @param[in] http_transaction The http transaction handle
- * @param[out] encoding encoding
+ * @remarks The @a encoding should be freed using free().
+ * @param[in] http_transaction The http transaction handle
+ * @param[out] encoding The encoding algorithms
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_request_get_accept_encoding(http_transaction_h http_transaction, char **encoding);
+int http_transaction_request_get_accept_encoding(http_transaction_h http_transaction, char **encoding);
+
+/**
+ * @brief Sets a cookie in the HTTP request.
+ * @since_tizen 3.0
+ * @remarks The format of string should be NME=CONTENTS (e.g. "name1=hello; name2=tizen;")
+ * @param[in] http_transaction The http transaction handle
+ * @param[in] cookie The cookie
+ * @return 0 on success, otherwise negative error value
+ * @retval #HTTP_ERROR_NONE Successful
+ * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
+ */
+int http_transaction_request_set_cookie(http_transaction_h http_transaction, const char *cookie);
+
+/**
+ * @brief Gets a cookie in the HTT request.
+ * @since_tizen 3.0
+ * @remarks The @a cookie should be freed using free().
+ * @param[in] http_transaction The http transaction handle
+ * @param[out] cookie The cookie
+ * @return 0 on success, otherwise negative error value
+ * @retval #HTTP_ERROR_NONE Successful
+ * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
+ */
+int http_transaction_request_get_cookie(http_transaction_h http_transaction, const char **cookie);
/**
- * @internal
* @brief Sets the request message body.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Sets the request message body.
- * @param[in] http_transaction The http transaction handle
- * @param[in] body message body data
+ * @param[in] http_transaction The http transaction handle
+ * @param[in] body The message body data
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_request_write_body(http_transaction_h http_transaction, const char *body);
+int http_transaction_request_write_body(http_transaction_h http_transaction, const char *body);
/**
* @}
*/
/**
- * @internal
* @addtogroup CAPI_NETWORK_HTTP_RESPONSE_MODULE
* @{
*/
/**
- * @internal
- * @brief Get the Http status code from Http Response.
+ * @brief Gets the Http status code from Http Response.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Get the Http status code from Http Response.
* @param[in] http_transaction The http transaction handle
- * @param[out] status_code http status code
+ * @param[out] status_code The http status code
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_response_get_status_code(http_transaction_h http_transaction, http_status_code_e *status_code);
+int http_transaction_response_get_status_code(http_transaction_h http_transaction, http_status_code_e *status_code);
/**
- * @internal
- * @brief Get the Http status text from Http Response.
+ * @brief Gets the Http status text from Http Response.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Get the Http status text from Http Response.
+ * @remarks The @a status_text should be freed using free().
* @param[in] http_transaction The http transaction handle
- * @param[out] status_text http status text
+ * @param[out] status_text The http status text
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_response_get_status_text(http_transaction_h http_transaction, char **status_text);
+int http_transaction_response_get_status_text(http_transaction_h http_transaction, char **status_text);
/**
- * @internal
- * @brief Get the Http version from Http Response.
+ * @brief Gets the Http version from Http Response.
* @since_tizen 3.0
- * @privlevel platform
- * @privilege http://tizen.org/privilege/http.admin
- * @details Get the Http version from Http Response.
* @param[in] http_transaction The http transaction handle
- * @param[out] version version
+ * @param[out] version The http version
* @return 0 on success, otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
*/
-int http_response_get_version(http_transaction_h http_transaction, http_version_e *version);
+int http_transaction_response_get_version(http_transaction_h http_transaction, http_version_e *version);
/**
* @}
curl_easy_setopt(transaction->easy_handle, CURLOPT_HTTPHEADER, header_list);
if (request->encoding)
- curl_easy_setopt(transaction->easy_handle, CURLOPT_ENCODING, request->encoding);
+ curl_easy_setopt(transaction->easy_handle, CURLOPT_ACCEPT_ENCODING, request->encoding);
if (request->cookie)
curl_easy_setopt(transaction->easy_handle, CURLOPT_COOKIE, request->cookie);
curl_easy_setopt(transaction->easy_handle, CURLOPT_WRITEFUNCTION, __handle_body_cb);
curl_easy_setopt(transaction->easy_handle, CURLOPT_WRITEDATA, transaction);
- http_header_get_field_value(transaction, "Content-Length", &field_value);
+ http_transaction_header_get_field_value(transaction, "Content-Length", &field_value);
if (field_value) {
content_len = atoi(field_value);
return NULL;
}
-API int http_open_transaction(http_session_h http_session, http_method_e method, http_transaction_h *http_transaction)
+API int http_session_open_transaction(http_session_h http_session, http_method_e method, http_transaction_h *http_transaction)
{
_retvm_if(http_session == NULL, HTTP_ERROR_INVALID_PARAMETER,
"parameter(http_session) is NULL\n");
__http_transaction_h *transaction = NULL;
- DBG("[Seonah] + ");
-
transaction = (__http_transaction_h *)malloc(sizeof(__http_transaction_h));
+ if (transaction == NULL) {
+ ERR("Fail to allocate transaction memory!!");
+ return HTTP_ERROR_OUT_OF_MEMORY;
+ }
+
transaction->easy_handle = NULL;
transaction->interface_name = NULL;
transaction->timeout = 0;
transaction->write_cb = NULL;
transaction->completed_cb = NULL;
transaction->aborted_cb = NULL;
-
- transaction->upload_progress_cb = NULL;
- transaction->download_progress_cb = NULL;
+ transaction->progress_cb = NULL;
transaction->session = http_session;
transaction->session->active_transaction_count++;
transaction->session_id = 0;
transaction->request = (__http_request_h *)malloc(sizeof(__http_request_h));
+ if (transaction->request == NULL) {
+ ERR("Fail to allocate request memory!!");
+ return HTTP_ERROR_OUT_OF_MEMORY;
+ }
+
transaction->response = (__http_response_h *)malloc(sizeof(__http_response_h));
+ if (transaction->response == NULL) {
+ ERR("Fail to allocate response memory!!");
+ return HTTP_ERROR_OUT_OF_MEMORY;
+ }
+
transaction->header = (__http_header_h *)malloc(sizeof(__http_header_h));
+ if (transaction->header == NULL) {
+ ERR("Fail to allocate header memory!!");
+ return HTTP_ERROR_OUT_OF_MEMORY;
+ }
transaction->request->host_uri = NULL;
transaction->request->method = _get_http_method(method);
transaction->request->cookie = NULL;
transaction->request->http_version = HTTP_VERSION_1_1;
transaction->request->body_queue = g_queue_new();
+ transaction->request->tot_size = 0;
transaction->header->header_list = NULL;
transaction->header->hash_table = NULL;
*http_transaction = (http_transaction_h)transaction;
_add_transaction_to_list(transaction);
- DBG("[Seonah] - ");
return HTTP_ERROR_NONE;
}
API int http_transaction_submit(http_transaction_h http_transaction)
{
_retvm_if(http_transaction == NULL, HTTP_ERROR_INVALID_PARAMETER,
- "parameter(http_transaction) is NULL\n");
+ "parameter(http_transaction) is NULL");
__http_transaction_h *transaction = (__http_transaction_h *)http_transaction;
+ _retvm_if(transaction->request->host_uri == NULL, HTTP_ERROR_INVALID_OPERATION, "URI isn't set!!");
+
transaction->thread = g_thread_new("transaction_thread", thread_callback, transaction);
return HTTP_ERROR_NONE;
}
-API int http_transaction_close(http_transaction_h http_transaction)
+API int http_transaction_destroy(http_transaction_h http_transaction)
{
_retvm_if(http_transaction == NULL, HTTP_ERROR_INVALID_PARAMETER,
"parameter(http_transaction) is NULL\n");
session->active_transaction_count--;
if (transaction) {
-
if (transaction->easy_handle != NULL) {
curl_easy_cleanup(transaction->easy_handle);
transaction->easy_handle = NULL;
transaction->write_cb = NULL;
transaction->completed_cb = NULL;
transaction->aborted_cb = NULL;
-
- transaction->upload_progress_cb = NULL;
- transaction->download_progress_cb = NULL;
+ transaction->progress_cb = NULL;
if (request) {
if (request->host_uri != NULL) {
return HTTP_ERROR_NONE;
}
-API int http_transaction_pause(http_transaction_h http_transaction, http_pause_state_e pause_state)
+API int http_transaction_pause(http_transaction_h http_transaction, http_pause_type_e pause_type)
{
_retvm_if(http_transaction == NULL, HTTP_ERROR_INVALID_PARAMETER,
"parameter(http_transaction) is NULL\n");
- _retvm_if(pause_state < HTTP_PAUSE_RECV || pause_state > HTTP_PAUSE_ALL, HTTP_ERROR_INVALID_PARAMETER,
+ _retvm_if(pause_type < HTTP_PAUSE_RECV || pause_type > HTTP_PAUSE_ALL, HTTP_ERROR_INVALID_PARAMETER,
"Wrong pause state \n");
__http_transaction_h *transaction = (__http_transaction_h *)http_transaction;
+ int ret = 0;
- curl_easy_pause(transaction->easy_handle, pause_state);
+ ret = curl_easy_pause(transaction->easy_handle, pause_type);
+ if (ret != 0) {
+ ERR("Fail to pause!(%d)", ret);
+ return HTTP_ERROR_OPERATION_FAILED;
+ }
return HTTP_ERROR_NONE;
}
"parameter(http_transaction) is NULL\n");
__http_transaction_h *transaction = (__http_transaction_h *)http_transaction;
+ int ret = 0;
- curl_easy_pause(transaction->easy_handle, CURLPAUSE_CONT);
+ ret = curl_easy_pause(transaction->easy_handle, CURLPAUSE_CONT);
+ if (ret != 0) {
+ ERR("Fail to resume!(%d)", ret);
+ return HTTP_ERROR_OPERATION_FAILED;
+ }
return HTTP_ERROR_NONE;
}
-API int http_transaction_set_progress_cb(http_transaction_h http_transaction, http_transaction_upload_progress_cb upload_progress_cb,
- http_transaction_download_progress_cb download_progress_cb)
+API int http_transaction_set_progress_cb(http_transaction_h http_transaction, http_transaction_progress_cb progress_cb, void* user_data)
{
_retvm_if(http_transaction == NULL, HTTP_ERROR_INVALID_PARAMETER,
"parameter(http_transaction) is NULL\n");
- _retvm_if(upload_progress_cb == NULL, HTTP_ERROR_INVALID_PARAMETER,
- "parameter(upload_progress_cb) is NULL\n");
- _retvm_if(download_progress_cb == NULL, HTTP_ERROR_INVALID_PARAMETER,
- "parameter(download_progress_cb) is NULL\n");
+ _retvm_if(progress_cb == NULL, HTTP_ERROR_INVALID_PARAMETER,
+ "parameter(progress_cb) is NULL\n");
__http_transaction_h *transaction = (__http_transaction_h *)http_transaction;
- transaction->upload_progress_cb = upload_progress_cb;
- transaction->download_progress_cb = download_progress_cb;
+ transaction->progress_cb = progress_cb;
+ transaction->progress_user_data = user_data;
return HTTP_ERROR_NONE;
}
return HTTP_ERROR_NONE;
}
-API int http_transaction_set_aborted_cb(http_transaction_h http_transaction, http_transaction_aborted_cb aborted_cb, void* user_data)
+API int http_transaction_set_aborted_cb(http_transaction_h http_transaction, http_transaction_aborted_cb aborted_cb, void* user_data)
{
_retvm_if(http_transaction == NULL, HTTP_ERROR_INVALID_PARAMETER,
- "parameter(http_transaction) is NULL\n");
+ "parameter(http_transaction) is NULL\n");
_retvm_if(aborted_cb == NULL, HTTP_ERROR_INVALID_PARAMETER,
"parameter(aborted_cb) is NULL\n");
__http_transaction_h *transaction = (__http_transaction_h *)http_transaction;
transaction->aborted_cb = aborted_cb;
- transaction->aborted_user_data = user_data;
return HTTP_ERROR_NONE;
}
"parameter(http_transaction) is NULL\n");
__http_transaction_h *transaction = (__http_transaction_h *)http_transaction;
-
- transaction->upload_progress_cb = NULL;
- transaction->download_progress_cb = NULL;
+ transaction->progress_cb = NULL;
return HTTP_ERROR_NONE;
}
return HTTP_ERROR_NONE;
}
-API int http_transaction_close_all(http_session_h http_session)
+API int http_session_destroy_all_transactions(http_session_h http_session)
{
_retvm_if(http_session == NULL, HTTP_ERROR_INVALID_PARAMETER,
"parameter(http_session) is NULL\n");
+ int ret = 0;
GSList *list = NULL;
__http_session_h *session = (__http_session_h *)http_session;
for (list = transaction_list; list; list = list->next) {
__http_transaction_h *transaction = (__http_transaction_h *)list->data;
if (session->session_id == transaction->session_id) {
- DBG("[Seonah]Close.. (%p)", list->data);
_remove_transaction_from_list(list->data);
- DBG("[Seonah]Close..1");
- http_transaction_close((http_transaction_h) transaction);
- DBG("[Seonah]Close..11");
+ ret = http_transaction_destroy((http_transaction_h) transaction);
+ if (ret != HTTP_ERROR_NONE) {
+ ERR("Fail to destroy transaction!!");
+ return HTTP_ERROR_OPERATION_FAILED;
+ }
}
}
#include "http.h"
-static GMainLoop *mainloop = NULL;
-
+#define ERR(x, y) printf("[ERR] %s(%d)\n", x, y)
+#define PRG(x, y) printf("[PRG] %s(%p)\n", x, y)
#define DBG printf
+#define MAX_URI_LEN 1024
FILE* fp1 = NULL;
FILE* fp2 = NULL;
-http_session_h session_handle = NULL;
-http_transaction_h transaction_handle1 = NULL;
-http_transaction_h transaction_handle2 = NULL;
-int count = 0;
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-int add_http_header(http_transaction_h transaction_handle)
+/////////////////Callbacks////////////////////////////////////////////////////////////////////////////
+void __transaction_header_cb(http_transaction_h transaction, char *header, size_t header_len, void *user_data)
{
- http_header_add_field(transaction_handle, "Connection", "close");
- //http_header_add_field(transaction_handle, "Accept-Charset", "ISO-8859-1,UTF-8;q=0.7,*;q=0.7");
- //http_header_add_field(transaction_handle, "Cache-Control", "no-cache");
- //http_header_add_field(transaction_handle, "Accept-Language", "en-us;q=0.3");
-
- return 0;
+ PRG("transaction_header_cb", transaction);
}
-int remove_http_header(http_transaction_h transaction_handle)
+void __transaction_body_cb(http_transaction_h transaction, char *body, size_t size, size_t nmemb, void *user_data)
{
- http_header_remove_field(transaction_handle, "Connection");
- //http_header_remove_field(transaction_handle, "Accept-Charset");
- //http_header_remove_field(transaction_handle, "Cache-Control");
- //http_header_remove_field(transaction_handle, "Accept-Language");
-
- return 0;
+ PRG("transaction_body_cb", transaction);
+ int written = size * nmemb;
+ DBG("Received: %d\n", written);
}
-void print_response_header(http_transaction_h transaction_handle)
+void __transaction_write_cb(http_transaction_h transaction, int recommended_chunk_size, void *user_data)
{
- char* uri = NULL;
- char* status_text = NULL;
- http_status_code_e status_code;
- http_version_e version;
-
- DBG("########################## Result #########################################\n");
-
- http_request_get_uri(transaction_handle, &uri);
- http_response_get_version(transaction_handle, &version);
- http_response_get_status_code(transaction_handle, &status_code);
- http_response_get_status_text(transaction_handle, &status_text);
-
- DBG("URI(%s) HTTP version (%d) Status Code (%d) Status message (%s)\n", uri, version, status_code, status_text);
+ PRG("transaction_write_cb", transaction);
+ DBG("recommended_chunk_size:%d\n", recommended_chunk_size);
}
-void close_transaction(http_transaction_h transaction_handle)
+void __transaction_completed_cb(http_transaction_h transaction, void *user_data)
{
- remove_http_header(transaction_handle);
-
- http_transaction_close(transaction_handle);
+ PRG("transaction_completed_cb", transaction);
- //transaction_handle = NULL;
-}
+ http_status_code_e status = 0;
+ int ret;
+ char *uri = NULL;
-void delete_session(http_session_h session)
-{
- http_transaction_close_all(session_handle);
+ ret = http_transaction_request_get_uri(transaction, &uri);
+ ret = http_transaction_response_get_status_code(transaction, &status);
- http_delete_session(session_handle);
- session_handle = NULL;
- http_deinit();
+ DBG("%s - status(%d)\n", uri, status);
+ ret = http_transaction_destroy(transaction);
+ if (ret == HTTP_ERROR_NONE) DBG("Success to close transaction\n");
+ else DBG("Fail to close transaction\n");
}
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////Callbacks////////////////////////////////////////////////////////////////////////////
-void transaction_header_cb(http_transaction_h transaction_handle, char *header, size_t header_len, void *user_data)
+void __transaction_aborted_cb(http_transaction_h transaction, http_error_code_e error, void *user_data)
{
- DBG("########################## transaction_header_cb(%p)#########################################\n", transaction_handle);
-
+ PRG("transaction_aborted_cb", transaction);
+ DBG("aborted reason: %d\n", error);
}
-void transaction_body_cb(http_transaction_h transaction_handle, char *body, size_t size, size_t nmemb, void *user_data)
+void _register_callbacks(http_transaction_h transaction)
{
- DBG("########################## transaction_body_cb(%p)#########################################\n", transaction_handle);
- int written = size * nmemb;
- DBG("Received: %d\n", written);
- //if (written) {
- //fwrite(body, size, nmemb, fp1);
- //}
+ http_transaction_set_received_header_cb(transaction, __transaction_header_cb, NULL);
+ http_transaction_set_received_body_cb(transaction, __transaction_body_cb, NULL);
+ http_transaction_set_uploaded_cb(transaction, __transaction_write_cb, NULL);
+ http_transaction_set_completed_cb(transaction, __transaction_completed_cb, NULL);
+ http_transaction_set_aborted_cb(transaction, __transaction_aborted_cb, NULL);
}
-void transaction_write_cb(http_transaction_h transaction_handle, int recommended_chunk_size, void *user_data)
+int test_http_init(void)
{
- DBG("########################## transaction_write_cb(%p)#########################################\n", transaction_handle);
-
- DBG("recommended_chunk_size:%d\n", recommended_chunk_size);
+ int ret = http_init();
+ if (ret == HTTP_ERROR_NONE)
+ return 1;
+ else return 0;
}
-void transaction_completed_cb(http_transaction_h transaction_handle, void *user_data)
+int test_http_deinit(void)
{
- DBG("########################## transaction_completed_cb(%p)#########################################\n", transaction_handle);
-
- char *uri = NULL;
-
- http_request_get_uri(transaction_handle, &uri);
- DBG("Completed uri: %s\n", uri);
- print_response_header(transaction_handle);
- count--;
-
- if (count == 0)
- g_main_loop_quit((GMainLoop*)mainloop);
+ int ret = http_deinit();
+ if (ret == HTTP_ERROR_NONE)
+ return 1;
+ else return 0;
}
-void transaction_aborted_cb(http_transaction_h transaction_handle, int reason, void *user_data)
+int test_simple_get(void)
{
- DBG("########################## transaction_aborted_cb(%p)#########################################\n", transaction_handle);
-
- close_transaction(transaction_handle);
- count--;
-
- if (count == 0)
- g_main_loop_quit((GMainLoop*)mainloop);
+ char uri[1024];
+ int ret;
+ http_session_h session = NULL;
+ http_transaction_h transaction = NULL;
+ http_method_e method;
+
+ printf("Input uri: ");
+ ret = scanf("%1023s", uri);
+
+ ret = http_session_create(HTTP_SESSION_MODE_NORMAL, &session);
+ if (ret != 0) {
+ ERR("Fail to create session", ret);
+ return 0;
+ }
+
+ ret = http_session_open_transaction(session, HTTP_METHOD_GET, &transaction);
+ if (ret != 0) {
+ ERR("Fail to open transaction", ret);
+ return 0;
+ }
+
+ http_transaction_request_get_method(transaction, &method);
+ ret = http_transaction_request_set_uri(transaction, uri);
+ if (ret != 0) {
+ ERR("Fail to set URI", ret);
+ return 0;
+ }
+
+ _register_callbacks(transaction);
+ ret = http_transaction_submit(transaction);
+
+ if (ret != 0) {
+ ERR("Fail to submit transaction", ret);
+ return 0;
+ }
+
+ return 1;
}
-http_transaction_h create_http_request(http_session_h session_handle, gchar* host_url)
+int test_multiple_get(void)
{
- http_transaction_h transaction_handle = NULL;
-
- //http_session_set_auto_redirection(session_handle, TRUE);
-
- http_open_transaction(session_handle, HTTP_METHOD_GET, &transaction_handle);
-
- http_request_set_uri(transaction_handle, host_url);
- add_http_header(transaction_handle);
- count++;
-
- return transaction_handle;
+ int ret;
+ http_session_h session = NULL;
+ http_transaction_h transaction[10];
+ int count, session_mode;
+ int i;
+
+ printf("Input count of transactions(1~10): ");
+ ret = scanf("%d", &count);
+
+ printf("Select session mode(0: NORMAL 1: PIPELINING): ");
+ ret = scanf("%d", &session_mode);
+
+ ret = http_session_create(session_mode, &session);
+ if (ret != 0) {
+ ERR("Fail to create session", ret);
+ return 0;
+ }
+
+ for (i = 0; i < count; i++) {
+ char uri[1024];
+ printf("Input uri for transaction[%d]: ", i + 1);
+ ret = scanf("%1023s", uri);
+ ret = http_session_open_transaction(session, HTTP_METHOD_GET, &transaction[i]);
+ if (ret != 0) {
+ ERR("Fail to open transaction", ret);
+ return 0;
+ }
+ ret = http_transaction_request_set_uri(transaction[i], uri);
+ if (ret != 0) {
+ ERR("Fail to set URI", ret);
+ return 0;
+ }
+ _register_callbacks(transaction[i]);
+ http_transaction_submit(transaction[i]);
+ }
+
+ return 1;
}
-int submit_http_request(http_transaction_h transaction_handle)
+gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
{
- http_transaction_submit(transaction_handle);
-
- return 0;
+ int rv;
+ char a[10];
+
+ printf("Event received from stdin\n");
+
+ rv = read(0, a, 10);
+
+ if (rv <= 0 || a[0] == '0')
+ exit(1);
+
+ if (a[0] == '\n' || a[0] == '\r') {
+ printf("\n\n Network Connection API Test App\n\n");
+ printf("Options..\n");
+ printf("1 - Initialize\n");
+ printf("2 - Deinitialize\n");
+ printf("3 - Simple GET\n");
+ printf("4 - Multiple GET\n");
+ printf("5 - \n");
+ printf("6 - \n");
+ printf("0 - Exit \n");
+ printf("ENTER - Show options menu.......\n");
+ }
+
+ switch (a[0]) {
+ case '1':
+ rv = test_http_init();
+ break;
+ case '2':
+ rv = test_http_deinit();
+ break;
+ case '3':
+ rv = test_simple_get();
+ break;
+ case '4':
+ rv = test_multiple_get();
+ break;
+ case '5':
+ break;
+ case '6':
+ break;
+ }
+
+ if (rv == 1)
+ printf("Operation succeeded!\n");
+ else
+ printf("Operation failed!\n");
+
+ return true;
}
-int main()
+int main(int argc, char **argv)
{
- DBG("########################## main:Enter#########################################\n");
-
- mainloop = g_main_loop_new(NULL, FALSE);
-
- http_init();
+ GMainLoop *mainloop;
- http_create_session(&session_handle, HTTP_SESSION_MODE_NORMAL);
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
+#endif
+ mainloop = g_main_loop_new(NULL, false);
- transaction_handle1 = create_http_request(session_handle, "https://www.google.com");
- transaction_handle2 = create_http_request(session_handle, "http://www.naver.com");
+ GIOChannel *channel = g_io_channel_unix_new(0);
+ g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
+ printf("Test Thread created...\n");
+ g_main_loop_run(mainloop);
- http_transaction_set_server_certificate_verification(transaction_handle1, 0);
- http_transaction_set_received_header_cb(transaction_handle1, transaction_header_cb, NULL);
- http_transaction_set_received_body_cb(transaction_handle1, transaction_body_cb, NULL);
- http_transaction_set_uploaded_cb(transaction_handle1, transaction_write_cb, NULL);
- http_transaction_set_completed_cb(transaction_handle1, transaction_completed_cb, NULL);
- http_transaction_set_aborted_cb(transaction_handle1, transaction_aborted_cb, NULL);
-
- http_transaction_set_received_header_cb(transaction_handle2, transaction_header_cb, NULL);
- http_transaction_set_received_body_cb(transaction_handle2, transaction_body_cb, NULL);
- http_transaction_set_uploaded_cb(transaction_handle2, transaction_write_cb, NULL);
- http_transaction_set_completed_cb(transaction_handle2, transaction_completed_cb, NULL);
- http_transaction_set_aborted_cb(transaction_handle2, transaction_aborted_cb, NULL);
-
- DBG("transaction1(%p), transaction2(%p)\n", transaction_handle1, transaction_handle2);
- submit_http_request(transaction_handle1);
- submit_http_request(transaction_handle2);
+ return 0;
+}
- g_main_loop_run(mainloop);
- http_transaction_close_all(session_handle);
- delete_session(session_handle);
- DBG("########################## main:Exit#########################################\n");
- return 0;
-}