extern "C" {
#endif
-
-#ifndef TIZEN_ERROR_HTTP
-#define TIZEN_ERROR_HTTP -0x03000000
-#endif
-
-
/**
* @file http.h
*/
/**
* @brief Called when the HTTP header is received.
* @since_tizen 3.0
+ * @remarks The @a header should be released using free(). \n
+ * The @a header is available until @a http_transaction is released.
* @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
/**
* @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.
+ * #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
* @param[in] http_transaction The HTTP transaction handle
* @param[in] error The error code about aborted reason
* @brief Creates the HTTP session handle.
* @since_tizen 3.0
* @remarks The @a http_session should be released using http_session_destroy().
- * Opened transactions can't be submitted after destroying session handle.
+ * Opened transactions can't be submitted after destroying session handle.
* @param[in] mode The HTTP session mode
- * @param[out] http_session The HTTP session handle
+ * @param[out] http_session The HTTP session handle
* @return @c 0 on success,
* otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @brief Gets the number of active transactions in the current session.
* @since_tizen 3.0
* @param[in] http_session The HTTP session handle
- * @param[out] active_transaction_count The number of activated transactions
+ * @param[out] active_transaction_count The number of activated transactions
* @return @c 0 on success,
* otherwise negative error value
* @retval #HTTP_ERROR_NONE Successful
* @since_tizen 3.0
* @privlevel public
* @privilege %http://tizen.org/privilege/internet \n
- * %http://tizen.org/privilege/network.get
+ * %http://tizen.org/privilege/network.get
* @param[in] http_transaction The HTTP transaction handle
* @return @c 0 on success,
* otherwise negative error value
/**
* @brief Closes the HTTP transaction handle.
* @since_tizen 3.0
- * @remarks The @a transaction is released by http_transaction_destroy().
- * http_transaction should be set to NULL after using it.
+ * @remarks The @a http_transaction is released by http_transaction_destroy().
+ * http_transaction should be set to NULL after using it.
* @param[in] http_transaction The HTTP transaction handle
* @return @c 0 on success,
* otherwise negative error value
/**
* @brief Registers callback called when receives header.
* @since_tizen 3.0
- * @param[in] http_transaction The HTTP transaction handle
- * @param[in] header_cb The callback function to be called
+ * @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 @c 0 on success,
* otherwise negative error value
/**
* @brief Cancels the transaction.
* @details This function cancels the transaction.\n
- * The aborted callback is invoked after using it.
+ * The aborted callback is invoked after using it.
* @since_tizen 3.0
* @param[in] http_transaction The HTTP transaction handle
* @return @c 0 on success,
int http_transaction_get_server_certificate_verification(http_transaction_h http_transaction, bool* verify);
+/**
+ * @brief Sets the flag to allow TCP Fast Open.
+ * @since_tizen 5.0
+ * @param[in] http_transaction The HTTP transaction handle
+ * @param[in] enable The flag to enable TCP Fast Open
+ * @return @c 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_transaction_set_tcp_fastopen(http_transaction_h http_transaction, bool enable);
+
+/**
+ * @brief Gets the flag to allow TCP Fast Open.
+ * @since_tizen 5.0
+ * @param[in] http_transaction The HTTP transaction handle
+ * @param[out] enable The flag to enable TCP Fast Open
+ * @return @c 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_transaction_get_tcp_fastopen(http_transaction_h http_transaction, bool *enable);
+
/**
* @}
*/
/**
* @brief Writes the request message body.
* @details This function writes the request message body in the internal queue. \n
- * The written queue for request body is uploaded after invoking http_transaction_submit().
+ * The written queue for request body is uploaded after invoking http_transaction_submit().
* @since_tizen 3.0
* @param[in] http_transaction The HTTP transaction handle
* @param[in] body The message body data
* @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
* @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
+ * @retval #HTTP_ERROR_PERMISSION_DENIED Permission denied
*/
int http_transaction_request_set_upload_file(http_transaction_h http_transaction, const char *file_path);
* limitations under the License.
*/
+#include <linux/version.h>
+
#include "http.h"
#include "http_private.h"
}
//LCOV_EXCL_STOP
+ if (transaction->tcp_fastopen)
+ curl_easy_setopt(transaction->easy_handle, CURLOPT_TCP_FASTOPEN, 1L);
+
curl_easy_setopt(transaction->easy_handle, CURLOPT_HEADERFUNCTION, __handle_header_cb);
curl_easy_setopt(transaction->easy_handle, CURLOPT_HEADERDATA, transaction);
transaction->upload_event = FALSE;
transaction->verify_peer = TRUE;
transaction->ca_path = g_strdup(HTTP_DEFAULT_CA_PATH);
+ transaction->tcp_fastopen = 0;
transaction->error[0] = '\0';
transaction->cancel = 0;
transaction->timeout = 0;
transaction->verify_peer = 0;
+ transaction->tcp_fastopen = 0;
if (transaction->ca_path) {
free(transaction->ca_path);
return HTTP_ERROR_NONE;
}
+API int http_transaction_get_tcp_fastopen(http_transaction_h http_transaction, bool *enable)
+{
+ _retvm_if(_http_is_init() == false, HTTP_ERROR_INVALID_OPERATION,
+ "http isn't initialized");
+ _retvm_if(http_transaction == NULL, HTTP_ERROR_INVALID_PARAMETER,
+ "parameter(http_transaction) is NULL\n");
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)
+ return HTTP_ERROR_NOT_SUPPORTED;
+#else
+ __http_transaction_h *transaction = (__http_transaction_h *)http_transaction;
+ *enable = transaction->tcp_fastopen;
+ return HTTP_ERROR_NONE;
+#endif
+}
+
+API int http_transaction_set_tcp_fastopen(http_transaction_h http_transaction, bool enable)
+{
+ _retvm_if(_http_is_init() == false, HTTP_ERROR_INVALID_OPERATION,
+ "http isn't initialized");
+ _retvm_if(http_transaction == NULL, HTTP_ERROR_INVALID_PARAMETER,
+ "parameter(http_transaction) is NULL\n");
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)
+ return HTTP_ERROR_NOT_SUPPORTED;
+#else
+ __http_transaction_h *transaction = (__http_transaction_h *)http_transaction;
+ transaction->tcp_fastopen = enable;
+ return HTTP_ERROR_NONE;
+#endif
+}
+
//LCOV_EXCL_START
API int http_transaction_set_http_auth_scheme(http_transaction_h http_transaction, http_auth_scheme_e auth_scheme)
{