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 Called when the http header is received.
182 * @param[in] http_transaction The http transaction handle
183 * @param[in] header The header information of Http Transaction
184 * @param[in] header_len The length of the Http Transaction header
185 * @param[in] user_data The user data
186 * @see http_transaction_set_received_header_cb()
188 typedef void (*http_transaction_header_cb)(http_transaction_h http_transaction, char *header, size_t header_len, void *user_data);
191 * @brief Called when the http response is received.
193 * @param[in] http_transaction The http transaction handle
194 * @param[in] body Response information of Http Transaction
195 * @param[in] size Size in bytes of each element to be written
196 * @param[in] count Number of elements, each one with a size of size bytes
197 * @param[in] user_data The user data
198 * @see http_transaction_set_received_body_cb()
200 typedef void (*http_transaction_body_cb)(http_transaction_h http_transaction, char *body, size_t size, size_t count, void *user_data);
203 * @brief Called when the http ready to write event is received.
205 * @param[in] http_transaction The http transaction handle
206 * @param[in] recommended_chunk_size Recommended chunk length(bytes) of the Http transaction
207 * @param[in] user_data The user data
208 * @see http_transaction_set_uploaded_cb()
210 typedef void (*http_transaction_write_cb)(http_transaction_h http_transaction, int recommended_chunk_size, void *user_data);
213 * @brief Called when the http transaction is completed.
215 * @param[in] http_transaction The http transaction handle
216 * @param[in] user_data The user data
217 * @see http_transaction_set_completed_cb()
219 typedef void (*http_transaction_completed_cb)(http_transaction_h http_transaction, void *user_data);
222 * @brief Called when the http transaction is aborted.
223 * @details Following error codes can be delivered. \n
224 * #HTTP_ERROR_OPERATION_FAILED, \n
225 * #HTTP_ERROR_COULDNT_RESOLVE_HOST, \n
226 * #HTTP_ERROR_COULDNT_CONNECT, \n
227 * #HTTP_ERROR_OPERATION_TIMEDOUT, \n
228 * #HTTP_ERROR_SSL_CONNECT_ERROR
230 * @param[in] http_transaction The http transaction handle
231 * @param[in] error The error code about aborted reason
232 * @param[in] user_data The user data
233 * @see http_transaction_set_aborted_cb()
235 typedef void (*http_transaction_aborted_cb)(http_transaction_h http_transaction, http_error_code_e error, void *user_data);
238 * @brief Called to notify when the content body of the response message is being downloaded or uploaded.
240 * @param[in] http_transaction The http transaction handle
241 * @param[in] download_total The total length of the data (in bytes) to download
242 * @param[in] download_now The current length of the downloaded data (in bytes)
243 * @param[in] upload_total The total length of the data (in bytes) to upload
244 * @param[in] upload_now The current length of the uploaded data (in bytes)
245 * @param[in] user_data The user data
246 * @see http_transaction_set_progress_cb()
248 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);
251 * @brief Initializes the Http module.
253 * @return 0 on success, otherwise negative error value
254 * @retval #HTTP_ERROR_NONE Successful
255 * @retval #HTTP_ERROR_OPERATION_FAILED Operation failed
256 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
262 * @brief Deinitializes the Http module.
264 * @return 0 on success, otherwise negative error value
265 * @retval #HTTP_ERROR_NONE Successful
266 * @retval #HTTP_ERROR_OPERATION_FAILED Operation failed
267 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
270 int http_deinit(void);
277 * @addtogroup CAPI_NETWORK_HTTP_SESSION_MODULE
282 * @brief Creates the Http session handle.
284 * @remarks The @a http_session should be released using http_session_destroy(). \
285 * Opened transactions can't be submitted after destroing session handle.
286 * @param[in] mode The http session mode
287 * @param[out] http_session The http session handle
288 * @return 0 on success, otherwise negative error value
289 * @retval #HTTP_ERROR_NONE Successful
290 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
291 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
292 * @retval #HTTP_ERROR_OUT_OF_MEMORY Out of memory
293 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
294 * @see http_session_destroy()
296 int http_session_create(http_session_mode_e mode, http_session_h *http_session);
299 * @brief Destroys the Http session handle.
301 * @param[in] http_session The http session handle
302 * @return 0 on success, otherwise negative error value
303 * @retval #HTTP_ERROR_NONE Successful
304 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
305 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
306 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
307 * @see http_session_create()
309 int http_session_destroy(http_session_h http_session);
312 * @brief Opens Http transaction from the Http Session.
314 * @remarks The @a http_transaction should be released using http_transaction_destroy().
315 * @param[in] http_session The http session handle
316 * @param[in] method The http request method
317 * @param[out] http_transaction The http transaction 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_OUT_OF_MEMORY Out of memory
323 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
325 int http_session_open_transaction(http_session_h http_session, http_method_e method, http_transaction_h *http_transaction);
328 * @brief Sets the value to redirect the HTTP request automatically.
330 * @param[in] http_session The http session handle
331 * @param[in] auto_redirection The value which determines whether allow redirection or not
332 * @return 0 on success, otherwise negative error value
333 * @retval #HTTP_ERROR_NONE Successful
334 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
335 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
336 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
337 * @see http_session_get_auto_redirection()
339 int http_session_set_auto_redirection(http_session_h http_session, bool auto_redirection);
342 * @brief Gets the auto redirection for the HTTP request.
344 * @param[in] http_session The http session handle
345 * @param[out] auto_redirect The value of auto redirect
346 * @return 0 on success, otherwise negative error value
347 * @retval #HTTP_ERROR_NONE Successful
348 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
349 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
350 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
351 * @see http_session_set_auto_redirection()
353 int http_session_get_auto_redirection(http_session_h http_session, bool *auto_redirect);
356 * @brief Gets the number of active transactions in the current session.
358 * @param[in] http_session The http session handle
359 * @param[out] active_transaction_count The number of activated transactions
360 * @return 0 on success, otherwise negative error value
361 * @retval #HTTP_ERROR_NONE Successful
362 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
363 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
364 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
366 int http_session_get_active_transaction_count(http_session_h http_session, int *active_transaction_count);
369 * @brief Gets the maximum number of transactions for the current session.
371 * @param[in] http_session The http session handle
372 * @param[out] transaction_count The maximum transaction count
373 * @return 0 on success, otherwise negative error value
374 * @retval #HTTP_ERROR_NONE Successful
375 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
376 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
377 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
379 int http_session_get_max_transaction_count(http_session_h http_session, int *transaction_count);
382 * @brief Destroys all transaction.
384 * @param[in] http_session The http session handle
385 * @return 0 on success, otherwise negative error value
386 * @retval #HTTP_ERROR_NONE Successful
387 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
388 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
389 * @retval #HTTP_ERROR_OPERATION_fAILED Operation failed
390 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
392 int http_session_destroy_all_transactions(http_session_h http_session);
398 * @addtogroup CAPI_NETWORK_HTTP_TRANSACTION_MODULE
403 * @brief Submits the Http request.
406 * @privilege %http://tizen.org/privilege/internet
407 * @param[in] http_transaction The http transaction handle
408 * @return 0 on success, otherwise negative error value
409 * @retval #HTTP_ERROR_NONE Successful
410 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
411 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
412 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
413 * @retval #HTTP_ERROR_PERMISSION_DENIED Permission denied
415 int http_transaction_submit(http_transaction_h http_transaction);
418 * @brief Closes the http transaction handle.
420 * @remarks The @a transaction is released by http_transaction_destroy().
421 * It should be used after finishing http trasaction.
422 * @param[in] http_transaction The http transaction handle
423 * @return 0 on success, otherwise negative error value
424 * @retval #HTTP_ERROR_NONE Successful
425 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
426 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
427 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
428 * @see http_transaction_create()
430 int http_transaction_destroy(http_transaction_h http_transaction);
433 * @brief Registers callback called when receive header.
435 * @param[in] http_transaction The http transaction handle
436 * @param[in] header_cb The callback function to be called
437 * @param[in] user_data The user data passed to the callback function
438 * @return 0 on success, otherwise negative error value
439 * @retval #HTTP_ERROR_NONE Successful
440 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
441 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
442 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
444 int http_transaction_set_received_header_cb(http_transaction_h http_transaction, http_transaction_header_cb header_cb, void* user_data);
447 * @brief Registers callback called when receive body.
449 * @param[in] http_transaction The http transaction handle
450 * @param[in] body_cb The callback function to be called
451 * @param[in] user_data The user data passed to the callback function
452 * @return 0 on success, otherwise negative error value
453 * @retval #HTTP_ERROR_NONE Successful
454 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
455 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
456 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
458 int http_transaction_set_received_body_cb(http_transaction_h http_transaction, http_transaction_body_cb body_cb, void* user_data);
461 * @brief Registers callback called when write data.
463 * @param[in] http_transaction The http transaction handle
464 * @param[in] write_cb The callback function to be called
465 * @param[in] user_data The user data passed to the callback function
466 * @return 0 on success, otherwise negative error value
467 * @retval #HTTP_ERROR_NONE Successful
468 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
469 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
470 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
472 int http_transaction_set_uploaded_cb(http_transaction_h http_transaction, http_transaction_write_cb write_cb, void* user_data);
475 * @brief Registers callback called when transaction is completed.
477 * @param[in] http_transaction The http transaction handle
478 * @param[in] completed_cb The callback function to be called
479 * @param[in] user_data The user data passed to the callback function
480 * @return 0 on success, otherwise negative error value
481 * @retval #HTTP_ERROR_NONE Successful
482 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
483 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
484 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
486 int http_transaction_set_completed_cb(http_transaction_h http_transaction, http_transaction_completed_cb completed_cb, void* user_data);
489 * @brief Registers callback called when transaction is aborted.
491 * @param[in] http_transaction The http transaction handle
492 * @param[in] header_cb The callback function to be called
493 * @param[in] user_data The user data passed to the callback function
494 * @return 0 on success, otherwise negative error value
495 * @retval #HTTP_ERROR_NONE Successful
496 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
497 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
498 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
500 int http_transaction_set_aborted_cb(http_transaction_h http_http_transaction, http_transaction_aborted_cb aborted_cb, void* user_data);
504 * @brief Registers the progress callbacks.
505 * @details Registers callback that is called when data is uploaded/downloaded.
507 * @param[in] http_transaction The http transaction handle
508 * @param[in] progress_cb The callback function to be called
509 * @param[in] user_data The user data passed to the callback function
510 * @return 0 on success, otherwise negative error value
511 * @retval #HTTP_ERROR_NONE Successful
512 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
513 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
514 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
516 int http_transaction_set_progress_cb(http_transaction_h http_transaction, http_transaction_progress_cb progress_cb, void* user_data);
519 * @brief Sets the timeout in seconds that is the timeout for waiting the transaction.
520 * @details Sets the timeout in seconds that is the timeout for waiting the transaction. \n
521 * A timeout value of zero means an infinite timeout.
523 * @param[in] http_transaction The http transaction handle
524 * @param[in] timeout The timeout in seconds
525 * @return 0 on success, otherwise negative error value
526 * @retval #HTTP_ERROR_NONE Successful
527 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
528 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
529 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
531 int http_transaction_set_timeout(http_transaction_h http_transaction, int timeout);
534 * @brief Gets the time out in seconds for the transaction.
536 * @param[in] http_transaction The http transaction handle
537 * @param[out] timeout The timeout in seconds
538 * @return 0 on success, otherwise negative error value
539 * @retval #HTTP_ERROR_NONE Successful
540 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
541 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
542 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
544 int http_transaction_get_timeout(http_transaction_h http_transaction, int *timeout);
547 * @brief Resumes the transaction.
549 * @param[in] http_transaction The http transaction handle
550 * @return 0 on success, otherwise negative error value
551 * @retval #HTTP_ERROR_NONE Successful
552 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
553 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
554 * @retval #HTTP_ERROR_OPERATION_FAILED Operation failed
555 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
557 int http_transaction_resume(http_transaction_h http_transaction);
560 * @brief Pauses the transaction.
562 * @param[in] http_transaction The http transaction handle
563 * @param[in] pause_type The pause type of the connection
564 * @return 0 on success, otherwise negative error value
565 * @retval #HTTP_ERROR_NONE Successful
566 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
567 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
568 * @retval #HTTP_ERROR_OPERATION_FAILED Operation failed
569 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
571 int http_transaction_pause(http_transaction_h http_transaction, http_pause_type_e pause_type);
574 * @brief Sets ready to write event for a transaction.
576 * @param[in] http_transaction The http transaction handle
577 * @param[out] read_to_write Enable/disable ready to write
578 * @return 0 on success, otherwise negative error value
579 * @retval #HTTP_ERROR_NONE Successful
580 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
581 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
582 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
584 int http_transaction_set_ready_to_write(http_transaction_h http_transaction, bool read_to_write);
587 * @brief Sets the interface name.
589 * @param[in] http_transaction The http transaction handle
590 * @param[in] interface_name The interface name to use as outgoing network interface
591 * @return 0 on success, otherwise negative error value
592 * @retval #HTTP_ERROR_NONE Successful
593 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
594 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
595 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
597 int http_transaction_set_interface_name(http_transaction_h http_transaction, const char *interface_name);
600 * @brief Gets the interface name.
602 * @remarks The @a interface_name should be freed using free().
603 * @param[in] http_transaction The http transaction handle
604 * @param[out] interface_name The interface name
605 * @return 0 on success, otherwise negative error value
606 * @retval #HTTP_ERROR_NONE Successful
607 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
608 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
609 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
611 int http_transaction_get_interface_name(http_transaction_h http_transaction, char **interface_name);
614 * @brief Sets the flag to verify a server certificate.
615 * @details The verify determines whether verifies the peer's certificate.
617 * @param[in] http_transaction The http transaction handle
618 * @param[in] verify The flag to verify a server certificate; true means verifies; false means it doesn't.
619 * @return 0 on success, otherwise negative error value
620 * @retval #HTTP_ERROR_NONE Successful
621 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
622 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
623 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
625 int http_transaction_set_server_certificate_verification(http_transaction_h http_transaction, bool verify);
628 * @brief Gets the flag to verify a server certificate.
630 * @param[in] http_transaction The http transaction handle
631 * @param[out] verify The flag to verify a server certificate; true means verifies; false means it doesn't.
632 * @return 0 on success, otherwise negative error value
633 * @retval #HTTP_ERROR_NONE Successful
634 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
635 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
636 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
638 int http_transaction_get_server_certificate_verification(http_transaction_h http_transaction, bool* verify);
641 * @brief Adds a named field to header.
642 * @details Adds a named field, which is a <@c fieldName, @c fieldValue> pair, to the current instance of Http Transaction.
644 * @param[in] http_transaction The http transaction handle
645 * @param[in] field_name The http Header Field name
646 * @param[in] field_value The http Header Field value
647 * @return 0 on success, otherwise negative error value
648 * @retval #HTTP_ERROR_NONE Successful
649 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
650 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
651 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
653 int http_transaction_header_add_field(http_transaction_h http_transaction, const char *field_name, const char* field_value);
656 * @brief Removes the named field from header.
657 * @details Remove the named field, which is a <@c fieldName, @c fieldValue> pair, from the current instance of Http Transaction.
659 * @param[in] http_transaction The http transaction handle
660 * @param[in] field_name The http Header Field name
661 * @return 0 on success, otherwise negative error value
662 * @retval #HTTP_ERROR_NONE Successful
663 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
664 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
665 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
667 int http_transaction_header_remove_field(http_transaction_h http_transaction, const char *field_name);
670 * @brief Gets the Http Header Field value from custom header.
672 * @remarks The @a field_value should be freed using free().
673 * @param[in] http_transaction The http transaction handle
674 * @param[in] field_name The http Header Field name
675 * @param[out] field_value The http Header Field value
676 * @return 0 on success, otherwise negative error value
677 * @retval #HTTP_ERROR_NONE Successful
678 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
679 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
680 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
682 int http_transaction_header_get_field_value(http_transaction_h http_transaction, const char *field_name, char **field_value);
689 * @addtogroup CAPI_NETWORK_HTTP_REQUEST_MODULE
694 * @brief Sets an HTTP method of the request header.
695 * @details Set an HTTP method such as GET, POST, PUT and etc.
697 * @remarks The default method is GET.
698 * @param[in] http_transaction The http transaction handle
699 * @param[in] method The http method
700 * @return 0 on success, otherwise negative error value
701 * @retval #HTTP_ERROR_NONE Successful
702 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
703 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
704 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
706 int http_transaction_request_set_method(http_transaction_h http_transaction, http_method_e method);
709 * @brief Gets the Http method from request header.
711 * @param[in] http_transaction The http transaction handle
712 * @param[out] method The http method
713 * @return 0 on success, otherwise negative error value
714 * @retval #HTTP_ERROR_NONE Successful
715 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
716 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
717 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
719 int http_transaction_request_get_method(http_transaction_h http_transaction, http_method_e *method);
722 * @brief Sets an HTTP version of the request header.
724 * @remarks The default version is HTTP 1.1.
725 * @param[in] http_transaction The http transaction handle
726 * @param[in] version The http version
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_version(http_transaction_h http_transaction, http_version_e version);
736 * @brief Gets the Http version from request header.
737 * @details Get the Http version.
739 * @param[in] http_transaction The http transaction handle
740 * @param[out] version The http version
741 * @return 0 on success, otherwise negative error value
742 * @retval #HTTP_ERROR_NONE Successful
743 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
744 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
745 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
747 int http_transaction_request_get_version(http_transaction_h http_transaction, http_version_e *version);
750 * @brief Sets a URI of the request header.
751 * @details Sets a URI of the request header.
753 * @remarks It should be used before http_transaction_submit().
754 * @param[in] http_transaction The http transaction handle
755 * @param[in] host_uri The uri to use in the request
756 * @return 0 on success, otherwise negative error value
757 * @retval #HTTP_ERROR_NONE Successful
758 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
759 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
760 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
762 int http_transaction_request_set_uri(http_transaction_h http_transaction, const char *host_uri);
765 * @brief Gets the uri.
767 * @remarks The @a host_uri should be freed using free().
768 * @param[in] http_transaction The http transaction handle
769 * @param[out] host_uri The host uri
770 * @return 0 on success, otherwise negative error value
771 * @retval #HTTP_ERROR_NONE Successful
772 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
773 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
774 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
776 int http_transaction_request_get_uri(http_transaction_h http_transaction, char **host_uri);
779 * @brief Sets the Accept-Encoding header field of HttpRequest.
780 * @details The Accept-Encoding header enables automatic decompression of HTTP downloads.
782 * @remarks If empty string is set, an Accept-Encoding header contains all supported built-in compressions.
783 * @param[in] http_transaction The http transaction handle
784 * @param[in] encoding The encoding algorithms (e.g. gizp, deflate)
785 * @return 0 on success, otherwise negative error value
786 * @retval #HTTP_ERROR_NONE Successful
787 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
788 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
789 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
791 int http_transaction_request_set_accept_encoding(http_transaction_h http_transaction, const char *encoding);
794 * @brief Gets the Accept-Encoding header field of HttpRequest.
796 * @remarks The @a encoding should be freed using free().
797 * @param[in] http_transaction The http transaction handle
798 * @param[out] encoding The encoding algorithms
799 * @return 0 on success, otherwise negative error value
800 * @retval #HTTP_ERROR_NONE Successful
801 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
802 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
803 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
805 int http_transaction_request_get_accept_encoding(http_transaction_h http_transaction, char **encoding);
808 * @brief Sets a cookie in the HTTP request.
810 * @remarks The format of string should be NME=CONTENTS (e.g. "name1=hello; name2=tizen;")
811 * @param[in] http_transaction The http transaction handle
812 * @param[in] cookie The cookie
813 * @return 0 on success, otherwise negative error value
814 * @retval #HTTP_ERROR_NONE Successful
815 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
816 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
817 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
819 int http_transaction_request_set_cookie(http_transaction_h http_transaction, const char *cookie);
822 * @brief Gets a cookie in the HTT request.
824 * @remarks The @a cookie should be freed using free().
825 * @param[in] http_transaction The http transaction handle
826 * @param[out] cookie The cookie
827 * @return 0 on success, otherwise negative error value
828 * @retval #HTTP_ERROR_NONE Successful
829 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
830 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
831 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
833 int http_transaction_request_get_cookie(http_transaction_h http_transaction, const char **cookie);
836 * @brief Writes the request message body.
837 * @details This function writes the request message body in the internal queue. \n
838 * The written queue for request body is uploaded after invoking http_transaction_submit()
840 * @param[in] http_transaction The http transaction handle
841 * @param[in] body The message body data
842 * @return 0 on success, otherwise negative error value
843 * @retval #HTTP_ERROR_NONE Successful
844 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
845 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
846 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
848 int http_transaction_request_write_body(http_transaction_h http_transaction, const char *body);
855 * @addtogroup CAPI_NETWORK_HTTP_RESPONSE_MODULE
860 * @brief Gets the Http status code from Http Response.
862 * @param[in] http_transaction The http transaction handle
863 * @param[out] status_code The http status code
864 * @return 0 on success, otherwise negative error value
865 * @retval #HTTP_ERROR_NONE Successful
866 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
867 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
868 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
870 int http_transaction_response_get_status_code(http_transaction_h http_transaction, http_status_code_e *status_code);
873 * @brief Gets the Http status text from Http Response.
875 * @remarks The @a status_text should be freed using free().
876 * @param[in] http_transaction The http transaction handle
877 * @param[out] status_text The http status text
878 * @return 0 on success, otherwise negative error value
879 * @retval #HTTP_ERROR_NONE Successful
880 * @retval #HTTP_ERROR_INVALID_PARAMETER Invalid parameter
881 * @retval #HTTP_ERROR_INVALID_OPERATION Invalid operation
882 * @retval #HTTP_ERROR_NOT_SUPPORTED Not Supported
884 int http_transaction_response_get_status_text(http_transaction_h http_transaction, char **status_text);
887 * @brief Gets the Http version from Http Response.
889 * @param[in] http_transaction The http transaction handle
890 * @param[out] version The http version
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_version(http_transaction_h http_transaction, http_version_e *version);
907 #endif /* __TIZEN_NETWORK_HTTP_H__ */