Wininet API function usage experience

Source: Internet
Author: User
Wininet API function usage experience
Copyright statement: original works can be reproduced. During reprinting, you must mark the original source, author information, and this statement in hyperlink form. Otherwise, legal liability will be held. Http://chenjava.blog.51cto.com/374566/84769
I. if you want to use httpqueryinfo after using httpsendrequestex, use httpendrequest to end request 2. bool httpqueryinfo (in hinternet hhttprequest, in DWORD dwinfolevel, in lpvoid lpvbuffer, in lpdword lpdwbufferlength, in out lpdword lpdwindex,); lpdwbufferlength returns the required buffer size, therefore, if you use this function multiple times, you need to assign values to lpdwbufferlength multiple times. Otherwise, the error_insufficient_buffer error sample program: hhttpfile = httpopenrequest (hconnect, "Post", "/avlab/index. PHP ", null, null, 0, protocol | Protocol | internet_flag_keep_connection | internet_flag_reload, 0); httpaddrequestheaders (hhttpfile, szcookie,-1, Protocol); httpaddrequestheaders (hhttpfile, "Content-Type: Application/X-WWW-form-urlencoded",-1, http_addreq_flag_add); httpsendrequestex (hhttpfile, & struinterin, null, null); httpendrequest (hhttpfile, null, null, null );
Nlength = 512; // This sentence is very important, because the value httpqueryinfo (hhttpfile, http_query_set_cookie, szbuffer, (unsigned long *) & nlength, null); 3. when using internetreadfile, remember to compare the number of bytes that have been read to determine whether all data has been read. If internetreadfile does not read response data, subsequent requests will be drowned by response data, the server does not receive a timely response or no response. at this time, the httpsendrequest will fail. during string operations, check the return value to prevent subsequent code from performing illegal operations. if you submit a get or POST command with parameters to a webpage, the website needs to process the time. The content of the returned URL may not have been updated. If you need to obtain the updated content, you need Compare the content before and after the update. if response is not received after httpsendrequest or httpsendrequestex sends a message, null is returned. The error code is set to 12002, indicating a timeout error. You can use internetsetoption (hhttpfile, internet_option_send_timeout, & timeout, sizeof (DWORD); set the timeout period 7. you cannot rely too much on the file size provided by the server. Sometimes the server does not provide the file size. If you use httpqueryinfo to obtain the file size again, an error occurs. The returned value of getlasterror () is 12150. Problem: 1. how does a webpage send commands? Where is the content of the command it sends stored? In addition to creating an HTTP header, it can also fill in the HTTP message body? 2. it's a strange thing. The HTTP message is related to the multipart Part separator. It will fail to be sent under some delimiters. In this article, the naming rules of the delimiters are found in the blog "Empty blank altar, be sure to keep this source http://chenjava.blog.51cto.com/374566/84769

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.