http/1.1 Continue-i served you.

Source: Internet
Author: User

Today, send an HTTP request using the C socket (): Upload an image to the server.

Locally tested, local PC: XP, iis5.1

After half a day of understanding the HTTP Post File protocol, the code has been written, the test found that the socket using the HTTP protocol to upload files, the server has been able to properly receive, and save the data to the newly generated file, but the client socket sent all the data, The results are displayed when the data returned from the server is read:

http/1.1 Continue

server:microsoft-iis/5.1

Date:mon, 05:52:22 GMT

X-powered-by:asp.net

Not what I expected. http/1.1

Search for relevant information on the Internet to find out why:

100 The purpose of the status code is to allow the client to determine whether the server is willing to accept the message body sent by the client (based on the request header domain) before the client sends this request message body. In some cases, if the server refuses to view the message body, it is inappropriate or inefficient for the client to send the message body. )

In other words, the role of Expect:100-continue is to set the client and server to match the "Request header field" before the post data, which is the equivalent of a handshake. If the match starts with the body content, post data. Otherwise, error (417) unkown.

Source: http://hi.baidu.com/leo_han/item/9bdd1068bc6f7131ad3e8333

Other relevant information: http://zhidao.baidu.com/question/396434329.html

Http://www.laruence.com/2011/01/20/1840.html

I carefully examined the source code and sent no data related to expect:100-continue in the HTTP header.

I later test upload image to Win2003 (iis6.0), you can normally return to http/1.1 OK

That is, uploading to different systems on different servers, it is possible to return http/1.1 to Continue, or it may not be returned.

So what do I do when I finish the HTTP header part of Send () in the code?

I tested, if send the HTTP header part, then first recv (), if encounter iis5.1 will immediately receive http/1.1 Continue

When iis6.0 is encountered, it blocks until recv timeout, which can severely affect the performance of the processing.

Reception is not, neither receive nor.

The solution is, after sending the data, received two messages, write the program to filter out http/1.1 Continue, check if there is http/1.1 OK:

http/1.1 Continue

server:microsoft-iis/5.1

Date:mon, 07:12:52 GMT

X-powered-by:asp.net

http/1.1 OK

server:microsoft-iis/5.1

Date:mon, 07:12:52 GMT

X-powered-by:asp.net

Connection:close

Content-length:18

content-type:text/html; Charset=utf-8

SET-COOKIE:ASPSESSIONIDAQDQBASB=APILENHAPOJMNCDIANAHGHJM; path=/

Cache-control:private

Abc123131abcefgkad

----------------------------------------------------------------------------------------------

HTTP Post file simple protocol, my understanding is this:

Post/up/test.asp?action=submit http/1.1

Accept: */*

Accept-language:zh-cn

user-agent:mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; trident/4.0; CIBA)

Host:www

Content-type:multipart/form-data; Boundary=x580xo3z1x2yemam

content-length:144

Connection:close

\ r \ n

--x580xo3z1x2yemam

Content-disposition:form-data; Name= "pic"; Filename= "X.txt"

Content-type:image/jpeg

\ r \ n

file contents [binary data]

--x580xo3z1x2yemam--\r\n

One of the content-length:144 here is particularly important to note, this 144 = the size of all the contents of the black bold above added up

Source: http://blog.csdn.net/ruixj/article/details/5986063#t2

Source: http://www.cnblogs.com/cswuyg/archive/2013/07/11/3185164.html

Source: http://blog.csdn.net/xiaojianpitt/article/details/6856536

A detailed description of the HTTP header:

Http://www.cnblogs.com/pipelone/archive/2009/03/26/1422140.html

2014-03-31

http/1.1 Continue-i served you.

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.