2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __TIZEN_NETWORK_HTTP_H__
18 #define __TIZEN_NETWORK_HTTP_H__
27 #ifndef TIZEN_ERROR_HTTP
28 #define TIZEN_ERROR_HTTP -0x03000000
36 * @addtogroup CAPI_NETWORK_HTTP_MODULE
41 * @brief The HTTP Session handle.
44 typedef void * http_session_h;
47 * @brief The HTTP Transaction handle.
50 typedef void * http_transaction_h;
57 * @addtogroup CAPI_NETWORK_HTTP_SESSION_MODULE
62 * @brief Enumeration for the http session.
66 HTTP_SESSION_MODE_NORMAL, /**< The Normal Mode */
67 HTTP_SESSION_MODE_PIPELINING, /**< The Pipelining mode */
68 } http_session_mode_e;
75 * @addtogroup CAPI_NETWORK_HTTP_MODULE
80 * @brief Enumeration for the http method.
84 HTTP_METHOD_GET = 0x40, /**< The HTTP GET Method */
85 HTTP_METHOD_OPTIONS = 0x41, /**< The HTTP OPTIONS Method */
86 HTTP_METHOD_HEAD = 0x42, /**< The HTTP HEAD Method */
87 HTTP_METHOD_DELETE = 0x43, /**< The HTTP DELETE Method */
88 HTTP_METHOD_TRACE = 0x44, /**< The HTTP TRACE Method */
89 HTTP_METHOD_POST = 0x60, /**< The HTTP POST Method */
90 HTTP_METHOD_PUT = 0x61, /**< The HTTP PUT Method */
91 HTTP_METHOD_CONNECT = 0x70, /**< The HTTP CONNECT Method */
95 * @brief Enumeration for the http version.
99 HTTP_VERSION_1_0, /**< HTTP version 1.0 */
100 HTTP_VERSION_1_1 /**< HTTP version 1.1 */
104 * @brief Enumeration for transfer pause state
108 HTTP_PAUSE_RECV = 1 << 0, /**< Pause receiving data */
109 HTTP_PAUSE_SEND = 1 << 2, /**< Pause sending data */
110 HTTP_PAUSE_ALL = HTTP_PAUSE_RECV | HTTP_PAUSE_SEND /**< Pause both directions */
114 * @brief Enumeration for the http error code.
118 HTTP_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
119 HTTP_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
120 HTTP_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
121 HTTP_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
122 HTTP_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
123 HTTP_ERROR_OPERATION_FAILED = TIZEN_ERROR_HTTP|0x01, /**< Operation failed */
124 HTTP_ERROR_COULDNT_RESOLVE_HOST = TIZEN_ERROR_HTTP|0x06, /**< Couldn't resolve host */
125 HTTP_ERROR_COULDNT_CONNECT = TIZEN_ERROR_HTTP|0x07, /**< Couldn't Connect to host */
126 HTTP_ERROR_OPERATION_TIMEDOUT = TIZEN_ERROR_HTTP|0x28, /**< Timeout */
127 HTTP_ERROR_SSL_CONNECT_ERROR = TIZEN_ERROR_HTTP|0x35, /**< SSL Error */
128 HTTP_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< API is not supported */
132 * @brief Enumeration for the http status code.
136 HTTP_STATUS_UNDEFINED = 0, /**< The undefined status */
137 HTTP_STATUS_CONTINUE = 100, /**< The status code: 100 Continue */
138 HTTP_STATUS_SWITCHING_PROTOCOLS = 101, /**< The status code: 101 Switching Protocols */
139 HTTP_STATUS_OK = 200, /**< The status code: 200 OK */
140 HTTP_STATUS_CREATED = 201, /**< The status code: 201 Created */
141 HTTP_STATUS_ACCEPTED = 202, /**< The status code: 202 Accepted */
142 HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION = 203, /**< The status code: 203 Non-Authoritative Information */
143 HTTP_STATUS_NO_CONTENT = 204, /**< The status code: 204 No %Content */
144 HTTP_STATUS_RESET_CONTENT = 205, /**< The status code: 205 Reset %Content */
145 HTTP_STATUS_PARTIAL_CONTENT = 206, /**< The status code: 206 Partial %Content */
147 HTTP_STATUS_MULTIPLE_CHOICE = 300, /**< The status code: 300 Multiple Choices */
148 HTTP_STATUS_MOVED_PERMANENTLY = 301, /**< The status code: 301 Moved Permanently */
149 HTTP_STATUS_MOVED_TEMPORARILY = 302, /**< The status code: 302 Found */
150 HTTP_STATUS_SEE_OTHER = 303, /**< The status code: 303 See Other */
151 HTTP_STATUS_NOT_MODIFIED = 304, /**< The status code: 304 Not Modified */
152 HTTP_STATUS_USE_PROXY = 305, /**< The status code: 305 Use Proxy */
154 HTTP_STATUS_BAD_REQUEST = 400, /**< The status code: 400 Bad Request */
155 HTTP_STATUS_UNAUTHORIZED = 401, /**< The status code: 401 Unauthorized */
156 HTTP_STATUS_PAYMENT_REQUIRED = 402, /**< The status code: 402 Payment Required */
157 HTTP_STATUS_FORBIDDEN = 403, /**< The status code: 403 Forbidden */
158 HTTP_STATUS_NOT_FOUND = 404, /**< The status code: 404 Not Found */
159 HTTP_STATUS_METHOD_NOT_ALLOWED = 405, /**< The status code: 405 Method Not Allowed */
160 HTTP_STATUS_NOT_ACCEPTABLE = 406, /**< The status code: 406 Not Acceptable */
161 HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED = 407, /**< The status code: 407 Proxy Authentication Required */
162 HTTP_STATUS_REQUEST_TIME_OUT = 408, /**< The status code: 408 Request Timeout (not used) */
163 HTTP_STATUS_CONFLICT = 409, /**< The status code: 409 Conflict */
164 HTTP_STATUS_GONE = 410, /**< The status code: 410 Gone */
165 HTTP_STATUS_LENGTH_REQUIRED = 411, /**< The status code: 411 Length Required */
166 HTTP_STATUS_PRECONDITION_FAILED = 412, /**< The status code: 412 Precondition Failed */
167 HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE = 413, /**< The status code: 413 Request Entity Too Large (not used) */
168 HTTP_STATUS_REQUEST_URI_TOO_LARGE = 414, /**< The status code: 414 Request-URI Too Long (not used) */
169 HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415, /**< The status code: 415 Unsupported %Media Type */
171 HTTP_STATUS_INTERNAL_SERVER_ERROR = 500, /**< The status code: 500 Internal Server Error */
172 HTTP_STATUS_NOT_IMPLEMENTED = 501, /**< The status code: 501 Not Implemented */
173 HTTP_STATUS_BAD_GATEWAY = 502, /**< The status code: 502 Bad Gateway */
174 HTTP_STATUS_SERVICE_UNAVAILABLE = 503, /**< The status code: 503 Service Unavailable */
175 HTTP_STATUS_GATEWAY_TIME_OUT = 504, /**< The status code: 504 Gateway Timeout */
176 HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED = 505 /**< The status code: 505 HTTP Version Not Supported */
177 } http_status_code_e;
180 * @brief Enumeration for the http authentication schemes.
184 HTTP_AUTH_NONE = 0, /**< No authentication type */
185 HTTP_AUTH_PROXY_BASIC = 1, /**< The authentication type is Proxy Basic Authentication */
186 HTTP_AUTH_PROXY_MD5 = 2, /**< The authentication type is Proxy Digest Authentication */
187 HTTP_AUTH_WWW_BASIC = 3, /**< The authentication Type is HTTP Basic Authentication */
188 HTTP_AUTH_WWW_MD5 = 4, /**< The authentication type is HTTP Digest Authentication */
189 HTTP_AUTH_PROXY_NTLM = 5, /**< The authentication type is Proxy NTLM Authentication */
190 HTTP_AUTH_WWW_NTLM = 7, /**< The authentication type is NTLM Authentication */
191 HTTP_AUTH_WWW_NEGOTIATE = 8 /**< The authentication type is Negotiate Authentication */
192 } http_auth_scheme_e;
195 * @brief Called when the http header is received.
197 * @param[in] http_transaction The http transaction handle
198 * @param[in] header The header information of HTTP Transaction
199 * @param[in] header_len The length of the HTTP Transaction header
200 * @param[in] user_data The user data
201 * @see http_transaction_set_received_header_cb()
203 typedef void (*http_transaction_header_cb)(http_transaction_h http_transaction, char *header, size_t header_len, void *user_data);
206 * @brief Called when the http response is received.
208 * @param[in] http_transaction The http transaction handle
209 * @param[in] body Response information of HTTP Transaction
210 * @param[in] size Size in bytes of each element to be written
211 * @param[in] count Number of elements, each one with a size of size bytes
212 * @param[in] user_data The user data
213 * @see http_transaction_set_received_body_cb()
215 typedef void (*http_transaction_body_cb)(http_transaction_h http_transaction, char *body, size_t size, size_t count, void *user_data);
218 * @brief Called when the http ready to write event is received.
220 * @param[in] http_transaction The http transaction handle
221 * @param[in] recommended_chunk_size Recommended chunk length(bytes) of the HTTP transaction
222 * @param[in] user_data The user data
223 * @see http_transaction_set_uploaded_cb()
225 typedef void (*http_transaction_write_cb)(http_transaction_h http_transaction, int recommended_chunk_size, void *user_data);
228 * @brief Called when the http transaction is completed.
230 * @param[in] http_transaction The http transaction handle
231 * @param[in] user_data The user data
232 * @see http_transaction_set_completed_cb()
234 typedef void (*http_transaction_completed_cb)(http_transaction_h http_transaction, void *user_data);
237 * @brief Called when the http transaction is aborted.
238 * @details Following error codes can be delivered. \n
239 * #HTTP_ERROR_OPERATION_FAILED, \n
240 * #HTTP_ERROR_COULDNT_RESOLVE_HOST, \n
241 * #HTTP_ERROR_COULDNT_CONNECT, \n
242 * #HTTP_ERROR_OPERATION_TIMEDOUT, \n
243 * #HTTP_ERROR_SSL_CONNECT_ERROR
245 * @param[in] http_transaction The http transaction handle
246 * @param[in] error The error code about aborted reason
247 * @param[in] user_data The user data
248 * @see http_transaction_set_aborted_cb()
250 typedef void (*http_transaction_aborted_cb)(http_transaction_h http_transaction, http_error_code_e error, void *user_data);
253 * @brief Called to notify when the content body of the response message is being downloaded or uploaded.
255 * @param[in] http_transaction The http transaction handle
256 * @param[in] download_total The total length of the data (in bytes) to download
257 * @param[in] download_now The current length of the downloaded data (in bytes)
258 * @param[in] upload_total The total length of the data (in bytes) to upload
259 * @param[in] upload_now The current length of the uploaded data (in bytes)
260 * @param[in] user_data The user data
261 * @see http_transaction_set_progress_cb()
263 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);
266 * @brief Initializes the HTTP module.
268 * @return 0 on success, otherwise negative error value
269 * @retval #HTTP_ERROR_NONE Successful
270 * @retval #HTTP_ERROR_OPERATION_FAILED Operation failed
271 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
277 * @brief Deinitializes the HTTP module.
279 * @return 0 on success, otherwise negative error value
280 * @retval #HTTP_ERROR_NONE Successful
281 * @retval #HTTP_ERROR_OPERATION_FAILED Operation failed
282 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
285 int http_deinit(void);
292 * @addtogroup CAPI_NETWORK_HTTP_SESSION_MODULE
297 * @brief Creates the HTTP session handle.
299 * @remarks The @a http_session should be released using http_session_destroy(). \
300 * Opened transactions can't be submitted after destroying session handle.
301 * @param[in] mode The http session mode
302 * @param[out] http_session The http session handle
303 * @return 0 on success, otherwise negative error value
304 * @retval #HTTP_ERROR_NONE Successful
305 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
306 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
307 * @retval #HTTP_ERROR_OUT_OF_MEMORY Out of memory
308 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
309 * @see http_session_destroy()
311 int http_session_create(http_session_mode_e mode, http_session_h *http_session);
314 * @brief Destroys the HTTP session handle.
316 * @remarks http_session should be set to NULL after using it
317 * @param[in] http_session The http session handle
318 * @return 0 on success, otherwise negative error value
319 * @retval #HTTP_ERROR_NONE Successful
320 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
321 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
322 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
323 * @see http_session_create()
325 int http_session_destroy(http_session_h http_session);
328 * @brief Opens HTTP transaction from the HTTP Session.
330 * @remarks The @a http_transaction should be released using http_transaction_destroy().
331 * @param[in] http_session The http session handle
332 * @param[in] method The http request method
333 * @param[out] http_transaction The http transaction handle
334 * @return 0 on success, otherwise negative error value
335 * @retval #HTTP_ERROR_NONE Successful
336 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
337 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
338 * @retval #HTTP_ERROR_OUT_OF_MEMORY Out of memory
339 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
341 int http_session_open_transaction(http_session_h http_session, http_method_e method, http_transaction_h *http_transaction);
344 * @brief Sets the value to redirect the HTTP request automatically.
346 * @param[in] http_session The http session handle
347 * @param[in] auto_redirection The value which determines whether allow redirection or not
348 * @return 0 on success, otherwise negative error value
349 * @retval #HTTP_ERROR_NONE Successful
350 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
351 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
352 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
353 * @see http_session_get_auto_redirection()
355 int http_session_set_auto_redirection(http_session_h http_session, bool auto_redirection);
358 * @brief Gets the auto redirection for the HTTP request.
360 * @param[in] http_session The http session handle
361 * @param[out] auto_redirect The value of auto redirect
362 * @return 0 on success, otherwise negative error value
363 * @retval #HTTP_ERROR_NONE Successful
364 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
365 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
366 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
367 * @see http_session_set_auto_redirection()
369 int http_session_get_auto_redirection(http_session_h http_session, bool *auto_redirect);
372 * @brief Gets the number of active transactions in the current session.
374 * @param[in] http_session The http session handle
375 * @param[out] active_transaction_count The number of activated transactions
376 * @return 0 on success, otherwise negative error value
377 * @retval #HTTP_ERROR_NONE Successful
378 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
379 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
380 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
382 int http_session_get_active_transaction_count(http_session_h http_session, int *active_transaction_count);
385 * @brief Gets the maximum number of transactions for the current session.
387 * @param[in] http_session The http session handle
388 * @param[out] transaction_count The maximum transaction count
389 * @return 0 on success, otherwise negative error value
390 * @retval #HTTP_ERROR_NONE Successful
391 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
392 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
393 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
395 int http_session_get_max_transaction_count(http_session_h http_session, int *transaction_count);
398 * @brief Destroys all transaction.
400 * @remarks All http_transactions should be set to NULL after using it
401 * @param[in] http_session The http session handle
402 * @return 0 on success, otherwise negative error value
403 * @retval #HTTP_ERROR_NONE Successful
404 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
405 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
406 * @retval #HTTP_ERROR_OPERATION_FAILED Operation failed
407 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
409 int http_session_destroy_all_transactions(http_session_h http_session);
415 * @addtogroup CAPI_NETWORK_HTTP_TRANSACTION_MODULE
420 * @brief Submits the HTTP request.
423 * @privilege %http://tizen.org/privilege/internet \n
424 * %http://tizen.org/privilege/network.get
425 * @param[in] http_transaction The http transaction handle
426 * @return 0 on success, otherwise negative error value
427 * @retval #HTTP_ERROR_NONE Successful
428 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
429 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
430 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
431 * @retval #HTTP_ERROR_PERMISSION_DENIED Permission denied
433 int http_transaction_submit(http_transaction_h http_transaction);
436 * @brief Closes the http transaction handle.
438 * @remarks The @a transaction is released by http_transaction_destroy().
439 * http_transaction should be set to NULL after using it.
440 * @param[in] http_transaction The http transaction handle
441 * @return 0 on success, otherwise negative error value
442 * @retval #HTTP_ERROR_NONE Successful
443 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
444 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
445 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
446 * @see http_transaction_create()
448 int http_transaction_destroy(http_transaction_h http_transaction);
451 * @brief Registers callback called when receive header.
453 * @param[in] http_transaction The http transaction handle
454 * @param[in] header_cb The callback function to be called
455 * @param[in] user_data The user data passed to the callback function
456 * @return 0 on success, otherwise negative error value
457 * @retval #HTTP_ERROR_NONE Successful
458 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
459 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
460 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
462 int http_transaction_set_received_header_cb(http_transaction_h http_transaction, http_transaction_header_cb header_cb, void* user_data);
465 * @brief Registers callback called when receive body.
467 * @param[in] http_transaction The http transaction handle
468 * @param[in] body_cb The callback function to be called
469 * @param[in] user_data The user data passed to the callback function
470 * @return 0 on success, otherwise negative error value
471 * @retval #HTTP_ERROR_NONE Successful
472 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
473 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
474 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
476 int http_transaction_set_received_body_cb(http_transaction_h http_transaction, http_transaction_body_cb body_cb, void* user_data);
479 * @brief Registers callback called when write data.
481 * @param[in] http_transaction The http transaction handle
482 * @param[in] write_cb The callback function to be called
483 * @param[in] user_data The user data passed to the callback function
484 * @return 0 on success, otherwise negative error value
485 * @retval #HTTP_ERROR_NONE Successful
486 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
487 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
488 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
490 int http_transaction_set_uploaded_cb(http_transaction_h http_transaction, http_transaction_write_cb write_cb, void* user_data);
493 * @brief Registers callback called when transaction is completed.
495 * @param[in] http_transaction The http transaction handle
496 * @param[in] completed_cb The callback function to be called
497 * @param[in] user_data The user data passed to the callback function
498 * @return 0 on success, otherwise negative error value
499 * @retval #HTTP_ERROR_NONE Successful
500 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
501 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
502 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
504 int http_transaction_set_completed_cb(http_transaction_h http_transaction, http_transaction_completed_cb completed_cb, void* user_data);
507 * @brief Registers callback called when transaction is aborted.
509 * @param[in] http_transaction The http transaction handle
510 * @param[in] aborted_cb The callback function to be called
511 * @param[in] user_data The user data passed to the callback function
512 * @return 0 on success, otherwise negative error value
513 * @retval #HTTP_ERROR_NONE Successful
514 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
515 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
516 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
518 int http_transaction_set_aborted_cb(http_transaction_h http_transaction, http_transaction_aborted_cb aborted_cb, void* user_data);
521 * @brief Registers the progress callbacks.
522 * @details Registers callback that is called when data is uploaded/downloaded.
524 * @param[in] http_transaction The http transaction handle
525 * @param[in] progress_cb The callback function to be called
526 * @param[in] user_data The user data passed to the callback function
527 * @return 0 on success, otherwise negative error value
528 * @retval #HTTP_ERROR_NONE Successful
529 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
530 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
531 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
533 int http_transaction_set_progress_cb(http_transaction_h http_transaction, http_transaction_progress_cb progress_cb, void* user_data);
536 * @brief Sets the timeout in seconds that is the timeout for waiting the transaction.
537 * @details Sets the timeout in seconds that is the timeout for waiting the transaction. \n
538 * A timeout value of zero means an infinite timeout.
540 * @param[in] http_transaction The http transaction handle
541 * @param[in] timeout The timeout in seconds
542 * @return 0 on success, otherwise negative error value
543 * @retval #HTTP_ERROR_NONE Successful
544 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
545 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
546 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
548 int http_transaction_set_timeout(http_transaction_h http_transaction, int timeout);
551 * @brief Gets the time out in seconds for the transaction.
553 * @param[in] http_transaction The http transaction handle
554 * @param[out] timeout The timeout in seconds
555 * @return 0 on success, otherwise negative error value
556 * @retval #HTTP_ERROR_NONE Successful
557 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
558 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
559 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
561 int http_transaction_get_timeout(http_transaction_h http_transaction, int *timeout);
564 * @brief Resumes the transaction.
566 * @param[in] http_transaction The http transaction handle
567 * @return 0 on success, otherwise negative error value
568 * @retval #HTTP_ERROR_NONE Successful
569 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
570 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
571 * @retval #HTTP_ERROR_OPERATION_FAILED Operation failed
572 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
574 int http_transaction_resume(http_transaction_h http_transaction);
577 * @brief Pauses the transaction.
579 * @param[in] http_transaction The http transaction handle
580 * @param[in] pause_type The pause type of the connection
581 * @return 0 on success, otherwise negative error value
582 * @retval #HTTP_ERROR_NONE Successful
583 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
584 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
585 * @retval #HTTP_ERROR_OPERATION_FAILED Operation failed
586 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
588 int http_transaction_pause(http_transaction_h http_transaction, http_pause_type_e pause_type);
591 * @brief Sets ready to write event for a transaction.
593 * @param[in] http_transaction The http transaction handle
594 * @param[out] read_to_write Enable/disable ready to write
595 * @return 0 on success, otherwise negative error value
596 * @retval #HTTP_ERROR_NONE Successful
597 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
598 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
599 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
601 int http_transaction_set_ready_to_write(http_transaction_h http_transaction, bool read_to_write);
604 * @brief Sets the interface name.
606 * @param[in] http_transaction The http transaction handle
607 * @param[in] interface_name The interface name to use as outgoing network interface
608 * @return 0 on success, otherwise negative error value
609 * @retval #HTTP_ERROR_NONE Successful
610 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
611 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
612 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
614 int http_transaction_set_interface_name(http_transaction_h http_transaction, const char *interface_name);
617 * @brief Gets the interface name.
619 * @remarks The @a interface_name should be freed using free().
620 * @param[in] http_transaction The http transaction handle
621 * @param[out] interface_name The interface name
622 * @return 0 on success, otherwise negative error value
623 * @retval #HTTP_ERROR_NONE Successful
624 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
625 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
626 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
628 int http_transaction_get_interface_name(http_transaction_h http_transaction, char **interface_name);
631 * @brief Sets the flag to verify a server certificate.
632 * @details The verify determines whether verifies the peer's certificate.
634 * @param[in] http_transaction The http transaction handle
635 * @param[in] verify The flag to verify a server certificate; true means verifies; false means it doesn't.
636 * @return 0 on success, otherwise negative error value
637 * @retval #HTTP_ERROR_NONE Successful
638 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
639 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
640 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
642 int http_transaction_set_server_certificate_verification(http_transaction_h http_transaction, bool verify);
645 * @brief Gets the flag to verify a server certificate.
647 * @param[in] http_transaction The http transaction handle
648 * @param[out] verify The flag to verify a server certificate; true means verifies; false means it doesn't.
649 * @return 0 on success, otherwise negative error value
650 * @retval #HTTP_ERROR_NONE Successful
651 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
652 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
653 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
655 int http_transaction_get_server_certificate_verification(http_transaction_h http_transaction, bool* verify);
662 * @addtogroup CAPI_NETWORK_HTTP_HEADER_MODULE
667 * @brief Adds a named field to header.
668 * @details Adds a named field, which is a <@c fieldName, @c fieldValue> pair, to the current instance of HTTP Transaction.
670 * @param[in] http_transaction The http transaction handle
671 * @param[in] field_name The http Header Field name
672 * @param[in] field_value The http Header Field value
673 * @return 0 on success, otherwise negative error value
674 * @retval #HTTP_ERROR_NONE Successful
675 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
676 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
677 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
679 int http_transaction_header_add_field(http_transaction_h http_transaction, const char *field_name, const char* field_value);
682 * @brief Removes the named field from header.
683 * @details Remove the named field, which is a <@c fieldName, @c fieldValue> pair, from the current instance of HTTP Transaction.
685 * @param[in] http_transaction The http transaction handle
686 * @param[in] field_name The http Header Field name
687 * @return 0 on success, otherwise negative error value
688 * @retval #HTTP_ERROR_NONE Successful
689 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
690 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
691 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
693 int http_transaction_header_remove_field(http_transaction_h http_transaction, const char *field_name);
696 * @brief Gets the HTTP Header Field value from custom header.
698 * @remarks The @a field_value should be freed using free().
699 * @param[in] http_transaction The http transaction handle
700 * @param[in] field_name The http Header Field name
701 * @param[out] field_value The http Header Field value
702 * @return 0 on success, otherwise negative error value
703 * @retval #HTTP_ERROR_NONE Successful
704 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
705 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
706 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
708 int http_transaction_header_get_field_value(http_transaction_h http_transaction, const char *field_name, char **field_value);
716 * @addtogroup CAPI_NETWORK_HTTP_REQUEST_MODULE
721 * @brief Sets an HTTP method of the request header.
722 * @details Set an HTTP method such as GET, POST, PUT and etc.
724 * @remarks The default method is GET.
725 * @param[in] http_transaction The http transaction handle
726 * @param[in] method The http method
727 * @return 0 on success, otherwise negative error value
728 * @retval #HTTP_ERROR_NONE Successful
729 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
730 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
731 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
733 int http_transaction_request_set_method(http_transaction_h http_transaction, http_method_e method);
736 * @brief Gets the HTTP method from request header.
738 * @param[in] http_transaction The http transaction handle
739 * @param[out] method The http method
740 * @return 0 on success, otherwise negative error value
741 * @retval #HTTP_ERROR_NONE Successful
742 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
743 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
744 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
746 int http_transaction_request_get_method(http_transaction_h http_transaction, http_method_e *method);
749 * @brief Sets an HTTP version of the request header.
751 * @remarks The default version is HTTP 1.1.
752 * @param[in] http_transaction The http transaction handle
753 * @param[in] version The http version
754 * @return 0 on success, otherwise negative error value
755 * @retval #HTTP_ERROR_NONE Successful
756 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
757 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
758 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
760 int http_transaction_request_set_version(http_transaction_h http_transaction, http_version_e version);
763 * @brief Gets the HTTP version from request header.
764 * @details Get the HTTP version.
766 * @param[in] http_transaction The http transaction handle
767 * @param[out] version The http version
768 * @return 0 on success, otherwise negative error value
769 * @retval #HTTP_ERROR_NONE Successful
770 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
771 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
772 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
774 int http_transaction_request_get_version(http_transaction_h http_transaction, http_version_e *version);
777 * @brief Sets a URI of the request header.
778 * @details Sets a URI of the request header.
780 * @remarks It should be used before http_transaction_submit().
781 * @param[in] http_transaction The http transaction handle
782 * @param[in] host_uri The uri to use in the request
783 * @return 0 on success, otherwise negative error value
784 * @retval #HTTP_ERROR_NONE Successful
785 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
786 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
787 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
789 int http_transaction_request_set_uri(http_transaction_h http_transaction, const char *host_uri);
792 * @brief Gets the uri.
794 * @remarks The @a host_uri should be freed using free().
795 * @param[in] http_transaction The http transaction handle
796 * @param[out] host_uri The host uri
797 * @return 0 on success, otherwise negative error value
798 * @retval #HTTP_ERROR_NONE Successful
799 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
800 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
801 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
803 int http_transaction_request_get_uri(http_transaction_h http_transaction, char **host_uri);
806 * @brief Sets the Accept-Encoding header field of HTTP Request.
807 * @details The Accept-Encoding header enables automatic decompression of HTTP downloads.
809 * @remarks If empty string is set, an Accept-Encoding header contains all supported built-in compressions.
810 * @param[in] http_transaction The http transaction handle
811 * @param[in] encoding The encoding algorithms (e.g. gzip, deflate)
812 * @return 0 on success, otherwise negative error value
813 * @retval #HTTP_ERROR_NONE Successful
814 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
815 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
816 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
818 int http_transaction_request_set_accept_encoding(http_transaction_h http_transaction, const char *encoding);
821 * @brief Gets the Accept-Encoding header field of HTTP Request.
823 * @remarks The @a encoding should be freed using free().
824 * @param[in] http_transaction The http transaction handle
825 * @param[out] encoding The encoding algorithms
826 * @return 0 on success, otherwise negative error value
827 * @retval #HTTP_ERROR_NONE Successful
828 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
829 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
830 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
832 int http_transaction_request_get_accept_encoding(http_transaction_h http_transaction, char **encoding);
835 * @brief Sets a cookie in the HTTP request.
837 * @remarks The format of string should be NME=CONTENTS (e.g. "name1=hello; name2=tizen;")
838 * @param[in] http_transaction The http transaction handle
839 * @param[in] cookie The cookie
840 * @return 0 on success, otherwise negative error value
841 * @retval #HTTP_ERROR_NONE Successful
842 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
843 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
844 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
846 int http_transaction_request_set_cookie(http_transaction_h http_transaction, const char *cookie);
849 * @brief Gets a cookie in the HTTP request.
851 * @remarks The @a cookie should be freed using free().
852 * @param[in] http_transaction The http transaction handle
853 * @param[out] cookie The cookie
854 * @return 0 on success, otherwise negative error value
855 * @retval #HTTP_ERROR_NONE Successful
856 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
857 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
858 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
860 int http_transaction_request_get_cookie(http_transaction_h http_transaction, char **cookie);
863 * @brief Writes the request message body.
864 * @details This function writes the request message body in the internal queue. \n
865 * The written queue for request body is uploaded after invoking http_transaction_submit()
867 * @param[in] http_transaction The http transaction handle
868 * @param[in] body The message body data
869 * @return 0 on success, otherwise negative error value
870 * @retval #HTTP_ERROR_NONE Successful
871 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
872 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
873 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
875 int http_transaction_request_write_body(http_transaction_h http_transaction, const char *body);
882 * @addtogroup CAPI_NETWORK_HTTP_RESPONSE_MODULE
887 * @brief Gets the HTTP status code from HTTP Response.
889 * @param[in] http_transaction The http transaction handle
890 * @param[out] status_code The http status code
891 * @return 0 on success, otherwise negative error value
892 * @retval #HTTP_ERROR_NONE Successful
893 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
894 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
895 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
897 int http_transaction_response_get_status_code(http_transaction_h http_transaction, http_status_code_e *status_code);
900 * @brief Gets the HTTP status text from HTTP Response.
902 * @remarks The @a status_text should be freed using free().
903 * @param[in] http_transaction The http transaction handle
904 * @param[out] status_text The http status text
905 * @return 0 on success, otherwise negative error value
906 * @retval #HTTP_ERROR_NONE Successful
907 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
908 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
909 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
911 int http_transaction_response_get_status_text(http_transaction_h http_transaction, char **status_text);
914 * @brief Gets the HTTP version from HTTP Response.
916 * @param[in] http_transaction The http transaction handle
917 * @param[out] version The http version
918 * @return 0 on success, otherwise negative error value
919 * @retval #HTTP_ERROR_NONE Successful
920 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
921 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
922 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
924 int http_transaction_response_get_version(http_transaction_h http_transaction, http_version_e *version);
931 * @addtogroup CAPI_NETWORK_HTTP_AUTHENTICATION_MODULE
936 * @brief Opens HTTP transaction with authentication information.
938 * @remarks The @a http_auth_transaction should be released using http_transaction_destroy().
939 * @param[in] http_transaction The http transaction handle
940 * @param[out] http_auth_transaction The http transaction handle
941 * @return 0 on success, otherwise negative error value
942 * @retval #HTTP_ERROR_NONE Successful
943 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
944 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
945 * @retval #HTTP_ERROR_OUT_OF_MEMORY Out of memory
946 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
948 int http_transaction_open_authentication(http_transaction_h http_transaction, http_transaction_h *http_auth_transaction);
951 * @brief Sets an HTTP credentials.
952 * @details Set an HTTP authentication scheme such as username and password.
954 * @param[in] http_transaction The http transaction handle
955 * @param[in] user_name The http user name
956 * @param[in] password The http password
957 * @return 0 on success, otherwise negative error value
958 * @retval #HTTP_ERROR_NONE Successful
959 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
960 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
962 int http_transaction_set_credentials(http_transaction_h http_transaction, const char *user_name, const char *password);
965 * @brief Gets the username & password for the http credential.
967 * @remarks The @a user_name & @a password should be freed using free().
968 * @param[in] http_transaction The http transaction handle
969 * @param[out] user_name The http credential user name
970 * @param[out] password The http credential password
971 * @return 0 on success, otherwise negative error value
972 * @retval #HTTP_ERROR_NONE Successful
973 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
974 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
975 * @retval #HTTP_ERROR_OUT_OF_MEMORY Out of memory
976 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
978 int http_transaction_get_credentials(http_transaction_h http_transaction, char **user_name, char **password);
981 * @brief Sets an HTTP authentication scheme.
982 * @details Set an HTTP authentication scheme such as BASIC, MD5, NTLM and etc.
984 * @param[in] http_transaction The http transaction handle
985 * @param[in] auth_scheme The http authentication scheme
986 * @return 0 on success, otherwise negative error value
987 * @retval #HTTP_ERROR_NONE Successful
988 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
989 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
991 int http_transaction_set_http_auth_scheme(http_transaction_h http_transaction, http_auth_scheme_e auth_scheme);
994 * @brief Gets the HTTP authentication scheme.
996 * @param[in] http_transaction The http transaction handle
997 * @param[out] auth_scheme The http auth scheme value
998 * @return 0 on success, otherwise negative error value
999 * @retval #HTTP_ERROR_NONE Successful
1000 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
1001 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
1002 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
1004 int http_transaction_get_http_auth_scheme(http_transaction_h http_transaction, http_auth_scheme_e *auth_scheme);
1007 * @brief Gets the HTTP authentication realm.
1009 * @remarks The @a realm should be freed using free().
1010 * @param[in] http_transaction The http transaction handle
1011 * @param[out] realm The http realm value
1012 * @return 0 on success, otherwise negative error value
1013 * @retval #HTTP_ERROR_NONE Successful
1014 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
1015 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
1016 * @retval #HTTP_ERROR_OUT_OF_MEMORY Out of memory
1017 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
1019 int http_transaction_get_realm(http_transaction_h http_transaction, char **realm);
1029 #endif /* __TIZEN_NETWORK_HTTP_H__ */