Tizen Native API  4.0

The HTTP API provides functions for communication with server according to the HTTP protocol.

Required Header

#include <http.h>

Overview

The HTTP API provides functions for communication with server according to the HTTP protocol. Using the HTTP APIs, you can implement features that allow the users of your application to:

  • Manage HTTP session
  • Manage HTTP transaction
  • Send/Receive HTTP request/response

Functions

int http_init (void)
 Initializes the HTTP module.
int http_deinit (void)
 Deinitializes the HTTP module.

Typedefs

typedef void * http_session_h
 The HTTP Session handle.
typedef void * http_transaction_h
 The HTTP Transaction handle.
typedef void(* http_transaction_header_cb )(http_transaction_h http_transaction, char *header, size_t header_len, void *user_data)
 Called when the HTTP header is received.
typedef void(* http_transaction_body_cb )(http_transaction_h http_transaction, char *body, size_t size, size_t count, void *user_data)
 Called when the HTTP response is received.
typedef void(* http_transaction_write_cb )(http_transaction_h http_transaction, int recommended_chunk_size, void *user_data)
 Called when the HTTP ready to write event is received.
typedef void(* http_transaction_completed_cb )(http_transaction_h http_transaction, void *user_data)
 Called when the HTTP transaction is completed.
typedef void(* http_transaction_aborted_cb )(http_transaction_h http_transaction, http_error_code_e error, void *user_data)
 Called when the HTTP transaction is aborted.
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)
 Called to notify when the content body of the response message is being downloaded or uploaded.

Typedef Documentation

typedef void* http_session_h

The HTTP Session handle.

Since :
3.0
typedef void(* http_transaction_aborted_cb)(http_transaction_h http_transaction, http_error_code_e error, void *user_data)

Called when the HTTP transaction is aborted.

Following error codes can be delivered.
HTTP_ERROR_OPERATION_FAILED,
HTTP_ERROR_COULDNT_RESOLVE_HOST,
HTTP_ERROR_COULDNT_CONNECT,
HTTP_ERROR_OPERATION_TIMEDOUT,
HTTP_ERROR_SSL_CONNECT_ERROR.

Since :
3.0
Parameters:
[in]http_transactionThe HTTP transaction handle
[in]errorThe error code about aborted reason
[in]user_dataThe user data
See also:
http_transaction_set_aborted_cb()
typedef void(* http_transaction_body_cb)(http_transaction_h http_transaction, char *body, size_t size, size_t count, void *user_data)

Called when the HTTP response is received.

Since :
3.0
Parameters:
[in]http_transactionThe HTTP transaction handle
[in]bodyResponse information of HTTP Transaction
[in]sizeSize in bytes of each element to be written
[in]countNumber of elements, each one with a size of size bytes
[in]user_dataThe user data
See also:
http_transaction_set_received_body_cb()
typedef void(* http_transaction_completed_cb)(http_transaction_h http_transaction, void *user_data)

Called when the HTTP transaction is completed.

Since :
3.0
Parameters:
[in]http_transactionThe HTTP transaction handle
[in]user_dataThe user data
See also:
http_transaction_set_completed_cb()
typedef void* http_transaction_h

The HTTP Transaction handle.

Since :
3.0
typedef void(* http_transaction_header_cb)(http_transaction_h http_transaction, char *header, size_t header_len, void *user_data)

Called when the HTTP header is received.

Since :
3.0
Parameters:
[in]http_transactionThe HTTP transaction handle
[in]headerThe header information of HTTP Transaction
[in]header_lenThe length of the HTTP Transaction header
[in]user_dataThe user data
See also:
http_transaction_set_received_header_cb()
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)

Called to notify when the content body of the response message is being downloaded or uploaded.

Since :
3.0
Parameters:
[in]http_transactionThe HTTP transaction handle
[in]download_totalThe total length of the data (in bytes) to download
[in]download_nowThe current length of the downloaded data (in bytes)
[in]upload_totalThe total length of the data (in bytes) to upload
[in]upload_nowThe current length of the uploaded data (in bytes)
[in]user_dataThe user data
See also:
http_transaction_set_progress_cb()
typedef void(* http_transaction_write_cb)(http_transaction_h http_transaction, int recommended_chunk_size, void *user_data)

Called when the HTTP ready to write event is received.

Since :
3.0
Parameters:
[in]http_transactionThe HTTP transaction handle
[in]recommended_chunk_sizeRecommended chunk length(bytes) of the HTTP transaction
[in]user_dataThe user data
See also:
http_transaction_set_uploaded_cb()

Enumeration Type Documentation

Enumeration for the HTTP authentication schemes.

Since :
3.0
Enumerator:
HTTP_AUTH_NONE 

No authentication type

HTTP_AUTH_PROXY_BASIC 

The authentication type is Proxy Basic Authentication

HTTP_AUTH_PROXY_MD5 

The authentication type is Proxy Digest Authentication

HTTP_AUTH_WWW_BASIC 

The authentication Type is HTTP Basic Authentication

HTTP_AUTH_WWW_MD5 

The authentication type is HTTP Digest Authentication

HTTP_AUTH_PROXY_NTLM 

The authentication type is Proxy NTLM Authentication

HTTP_AUTH_WWW_NTLM 

The authentication type is NTLM Authentication

HTTP_AUTH_WWW_NEGOTIATE 

The authentication type is Negotiate Authentication

Enumeration for the HTTP error code.

Since :
3.0
Enumerator:
HTTP_ERROR_NONE 

Successful

HTTP_ERROR_OUT_OF_MEMORY 

Out of memory

HTTP_ERROR_PERMISSION_DENIED 

Permission denied

HTTP_ERROR_INVALID_PARAMETER 

Invalid parameter

HTTP_ERROR_INVALID_OPERATION 

Invalid operation

HTTP_ERROR_OPERATION_FAILED 

Operation failed

HTTP_ERROR_COULDNT_RESOLVE_HOST 

Couldn't resolve host

HTTP_ERROR_COULDNT_CONNECT 

Couldn't Connect to host

HTTP_ERROR_OPERATION_TIMEDOUT 

Timeout

HTTP_ERROR_SSL_CONNECT_ERROR 

SSL Error

HTTP_ERROR_CANCELED 

Operation Canceled

HTTP_ERROR_NOT_SUPPORTED 

API is not supported

Enumeration for the HTTP method.

Since :
3.0
Enumerator:
HTTP_METHOD_GET 

The HTTP GET Method

HTTP_METHOD_OPTIONS 

The HTTP OPTIONS Method

HTTP_METHOD_HEAD 

The HTTP HEAD Method

HTTP_METHOD_DELETE 

The HTTP DELETE Method

HTTP_METHOD_TRACE 

The HTTP TRACE Method

HTTP_METHOD_POST 

The HTTP POST Method

HTTP_METHOD_PUT 

The HTTP PUT Method

HTTP_METHOD_CONNECT 

The HTTP CONNECT Method

Enumeration for transfer pause state.

Since :
3.0
Enumerator:
HTTP_PAUSE_RECV 

Pause receiving data

HTTP_PAUSE_SEND 

Pause sending data

HTTP_PAUSE_ALL 

Pause both directions

Enumeration for the HTTP status code.

Since :
3.0
Enumerator:
HTTP_STATUS_UNDEFINED 

The undefined status

HTTP_STATUS_CONTINUE 

The status code: 100 Continue

HTTP_STATUS_SWITCHING_PROTOCOLS 

The status code: 101 Switching Protocols

HTTP_STATUS_OK 

The status code: 200 OK

HTTP_STATUS_CREATED 

The status code: 201 Created

HTTP_STATUS_ACCEPTED 

The status code: 202 Accepted

HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION 

The status code: 203 Non-Authoritative Information

HTTP_STATUS_NO_CONTENT 

The status code: 204 No Content

HTTP_STATUS_RESET_CONTENT 

The status code: 205 Reset Content

HTTP_STATUS_PARTIAL_CONTENT 

The status code: 206 Partial Content

HTTP_STATUS_MULTIPLE_CHOICE 

The status code: 300 Multiple Choices

HTTP_STATUS_MOVED_PERMANENTLY 

The status code: 301 Moved Permanently

HTTP_STATUS_MOVED_TEMPORARILY 

The status code: 302 Found

HTTP_STATUS_SEE_OTHER 

The status code: 303 See Other

HTTP_STATUS_NOT_MODIFIED 

The status code: 304 Not Modified

HTTP_STATUS_USE_PROXY 

The status code: 305 Use Proxy

HTTP_STATUS_BAD_REQUEST 

The status code: 400 Bad Request

HTTP_STATUS_UNAUTHORIZED 

The status code: 401 Unauthorized

HTTP_STATUS_PAYMENT_REQUIRED 

The status code: 402 Payment Required

HTTP_STATUS_FORBIDDEN 

The status code: 403 Forbidden

HTTP_STATUS_NOT_FOUND 

The status code: 404 Not Found

HTTP_STATUS_METHOD_NOT_ALLOWED 

The status code: 405 Method Not Allowed

HTTP_STATUS_NOT_ACCEPTABLE 

The status code: 406 Not Acceptable

HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED 

The status code: 407 Proxy Authentication Required

HTTP_STATUS_REQUEST_TIME_OUT 

The status code: 408 Request Timeout (not used)

HTTP_STATUS_CONFLICT 

The status code: 409 Conflict

HTTP_STATUS_GONE 

The status code: 410 Gone

HTTP_STATUS_LENGTH_REQUIRED 

The status code: 411 Length Required

HTTP_STATUS_PRECONDITION_FAILED 

The status code: 412 Precondition Failed

HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE 

The status code: 413 Request Entity Too Large (not used)

HTTP_STATUS_REQUEST_URI_TOO_LARGE 

The status code: 414 Request-URI Too Long (not used)

HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE 

The status code: 415 Unsupported Media Type

HTTP_STATUS_INTERNAL_SERVER_ERROR 

The status code: 500 Internal Server Error

HTTP_STATUS_NOT_IMPLEMENTED 

The status code: 501 Not Implemented

HTTP_STATUS_BAD_GATEWAY 

The status code: 502 Bad Gateway

HTTP_STATUS_SERVICE_UNAVAILABLE 

The status code: 503 Service Unavailable

HTTP_STATUS_GATEWAY_TIME_OUT 

The status code: 504 Gateway Timeout

HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED 

The status code: 505 HTTP Version Not Supported

Enumeration for the HTTP version.

Since :
3.0
Enumerator:
HTTP_VERSION_1_0 

HTTP version 1.0

HTTP_VERSION_1_1 

HTTP version 1.1


Function Documentation

int http_deinit ( void  )

Deinitializes the HTTP module.

Since :
3.0
Returns:
0 on success, otherwise negative error value
Return values:
HTTP_ERROR_NONESuccessful
HTTP_ERROR_OPERATION_FAILEDOperation failed
HTTP_ERROR_NOT_SUPPORTEDNot Supported
See also:
http_init()
int http_init ( void  )

Initializes the HTTP module.

Since :
3.0
Returns:
0 on success, otherwise negative error value
Return values:
HTTP_ERROR_NONESuccessful
HTTP_ERROR_OPERATION_FAILEDOperation failed
HTTP_ERROR_NOT_SUPPORTEDNot Supported
See also:
http_deinit()