Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 69 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
69
Dung lượng
5,31 MB
Nội dung
< previous page page_511 next page > Page 511 http_t *http; http = httpConnect(cupsServer(), ippPort()); See Also httpClose(), httpConnectEncrypt(), httpGet(), httpGets(), httpPost(), httpRead(), httpWrite() httpConnectEncrypt() Usage http_t * httpConnectEncrypt(const char *hostname, int port, http_encryption_t encryption); Arguments Argument Type Description hostname const char * The hostname or IP address of the server that is to be contacted port int The port number that is to be used encryption http_encryption_t The type of encryption that is to be used Returns A pointer to an HTTP connection structure or NULL if the connection could not be made. Description The httpConnectEncrypt() function opens an HTTP connection to the specified server and port using the specified encryption mode. Example #include <cups/http.h> http_t *http; http = httpConnectEncrypt(cupsServer(), ippPort(), HTTP_ENCRYPT_REQUIRED); < previous page page_511 next page > < previous page page_512 next page > Page 512 See Also httpClose(), httpConnect(), httpGet(), httpGets(), httpPost(), httpRead(), httpWrite() httpDecode64() Usage char * httpDecode64(char *out, const char *in); Arguments Argument Type Description out char * The output string in const char * The input string Returns A pointer to the decoded string. Description The httpDecode64() function decodes a base-64 encoded string to the original string. Example #include <cups/http.h> char encoded_string[255]; char original_string[255]; httpDecode64 (original_string, encoded_string); See Also httpEncode64() < previous page page_512 next page > < previous page page_513 next page > Page 513 httpDelete() Usage int httpDelete(http_t *http, const char *uri); Arguments Argument Type Description http http_t * The HTTP connection uri const char * The URI that is to be deleted Returns 0 on success, non-zero on failure. Description The httpDelete() function sends an HTTP DELETE request to the server. Example #include <cups/http.h> http_t *http; httpDelete(http, ''/some/uri"); See Also httpConnect(), httpSetField(), httpUpdate() httpEncode64() Usage char * httpEncode64(char *out, const char *in); < previous page page_513 next page > < previous page page_514 next page > Page 514 Arguments Argument Type Description out char * The output string in const char * The input string Returns A pointer to the encoded string. Description The httpEncode64() function decodes a base-64 encoded string to the original string. Example #include <cups/http.h> char encoded_string[255]; char original_string[255]; httpEncode64 (encoded_string, original_string); See Also httpDecode64() httpEncryption() Usage void httpEncryption(http_t *http, http_encryption_t encryption); Arguments Argument Type Description http http_t * The HTTP connection encryption http_encryption_t The type of encryption that is to be used < previous page page_514 next page > < previous page page_515 next page > Page 515 Description The httpEncryption() function sets the type of encryption that is to be used on the connection to the HTTP server. This function may close and reconnect to the server to establish the new type of encryption. Example #include <cups/http.h> http_t *http; httpEncryption(http, HTTP_ENCRYPT_REQUIRED); See Also httpConnectEncrypt() httpError() Usage int httpError(http_t *http); Arguments Argument Type Description http http_t * The HTTP connection Returns The last error that occurred or 0 if no error has occurred. Description The httpError() function returns the last error that occurred on the HTTP connection. Example #include <cups/http.h> http_t *http; < previous page page_515 next page > < previous page page_516 next page > Page 516 if (httpError(http)) { show an error message } See Also httpConnect() httpFlush() Usage void httpFlush(http_t *http); Arguments Argument Type Description http http_t * The HTTP connection Description The httpFlush() function flushes any remaining data left from a GET or POST operation. Example #include <cups/http.h> http_t *http; httpFlush(http); See Also httpConnect() < previous page page_516 next page > < previous page page_517 next page > Page 517 httpGet() Usage int httpGet(http_t *http, const char *uri); Arguments Argument Type Description http http_t * The HTTP connection uri const char * The URI to GET Returns 0 on success, non-zero on failure. Description The httpGet() function sends an HTTP GET request to the server. Example #include <cups/http.h> http_t *http; httpGet(http, ''/some/uri"); See Also httpConnect(), httpSetField(), httpUpdate() httpGetDateString() Usage const char * httpGetDateString(time_t time); < previous page page_517 next page > < previous page page_518 next page > Page 518 Arguments Argument Type Description time time_t The Unix date/time value Returns A pointer to a static string containing the HTTP date/time string for the specified Unix time value. Description The httpGetDateString() function generates a date/time string suitable for HTTP requests from a Unix time value. The date/time string is overwritten with each call. Example #include <cups/http.h> puts(httpGetDateString(time(NULL))); See Also httpGetDateTime() httpGetDateTime() Usage time_t httpGetDateTime(const char *date); Arguments Argument Type Description date const char * The HTTP date/time string Returns A Unix time value. < previous page page_518 next page > < previous page page_519 next page > Page 519 Description The httpGetDateTime() function converts an HTTP date/time string to a Unix time value. Example #include <cups/http.h> printf(''%d\n", httpGetDateTime("Fri, 30 June 2000 12:34:56 GMT")); See Also httpGetDateString() httpGetField() Usage const char * httpGetField(http_t *http, http_field_t field); Arguments Argument Type Description http http_t * The HTTP connection field http_field_t The HTTP field Returns A pointer to the field value string. Description The httpGetField() function returns the current value for the specified HTTP field. An empty field is represented by a string of 0 length. Example #include <cups/http.h> http_t *http; < previous page page_519 next page > < previous page page_520 next page > Page 520 httpGet(http, ''/some/uri"); while (httpUpdate(http) == HTTP_CONTINUE); puts(httpGetField(http, HTTP_FIELD_CONTENT_TYPE)); See Also httpGetSubField(), httpSetField() httpGetLength() Usage int httpGetLength(http_t *http); Arguments Argument Type Description http http_t * The HTTP connection Returns The content length of the GET or POST data. Description The httpGetLength() function returns the number of bytes returned by a GET or POST request. Example #include <cups/http.h> http_t *http; httpGet(http, "/some/uri"); while (httpUpdate(http) == HTTP_CONTINUE); printf("Content length = %d\n", httpGetLength(http)); < previous page page_520 next page > [...]... *http, const char *uri); Arguments Argument Type Description http http_t * The HTTP connection uri const char * The URI to POST to < previous page page_528 next page > < previous page page_5 29 next page > Page 5 29 Returns 0 on success, non-zero on failure Description The httpPost() function sends an HTTP POST request to the server Example #include http_t *http; httpPost(http, ''/some/uri");... ippAddIntegers(), ippAddRange(), ippAddRanges(), ippAddResolution(), ippAddResolutions(), ippAddSeparator(), ippAddString(), ippAddStrings() < previous page page_538 next page > < previous page page_5 39 next page > Page 5 39 ippAddBooleans() Usage ipp_attribute_t * ippAddBooleans(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, const char *values); Arguments Argument Type Description ipp ipp_t *... Argument Type Description http http_t * The HTTP connection format const char * A printf-style format string varies Additional arguments as needed Returns The number of bytes written < previous page page_5 29 next page > < previous page page_530 next page > Page 530 Description The httpPrintf() function sends a formatted string to the HTTP connection Normally, only the CUPS API and scheduler use it Example... ippAddBoolean(), ippAddDate(), ippAddInteger(), ippAddIntegers(), ippAddRange(), ippAddRanges(), ippAddResolution(), ippAddResolutions(), ippAddSeparator(), ippAddString(), ippAddStrings() < previous page page_5 39 next page > < previous page page_540 next page > Page 540 ippAddDate() Usage ipp_attribute_t * ippAddDate(ipp_t *ipp, ipp_tag_t group, const char *name, ipp_uchar_t *value); Arguments Argument Type Description . char * The HTTP date/time string Returns A Unix time value. < previous page page_518 next page > < previous page page_5 19 next page > Page 5 19 Description The httpGetDateTime() function. 518 Arguments Argument Type Description time time_t The Unix date/time value Returns A pointer to a static string containing the HTTP date/time string for the specified Unix time value. Description The httpGetDateString(). URI to POST to < previous page page_528 next page > < previous page page_5 29 next page > Page 5 29 Returns 0 on success, non-zero on failure. Description The httpPost() function sends