HTTP protocol version and Java return value discussion

Source: Internet
Author: User

Let's take a look at the difference between HTTP Protocols 1.0 and 1.1:

1.0:http 1.0 Specifies that the browser and the server only maintain a brief connection, each request of the browser needs to establish a TCP connection with the server, the server completes the request processing immediately after disconnecting the TCP connection, the server does not track each customer also does not log past requests:

1.1:http 1.1 supports persistent connections , which can transmit multiple HTTP requests and responses on a single TCP connection, reducing the consumption and latency of establishing and shutting down connections.

And look at the function of return in Java:

The return statement has two main uses: one to represent the value returned by a method (assuming there is no void return value) and, on the other hand, to cause the method to exit and return that value.

Problem:

In the development process, the local test all passed, but published to the line, found that directly with postman can access the request and can get the value (pending), but after the Nginx agent, with the domain name access to error, errors for provisional headers is shown, Start to feel that Nginx agent has a problem,

But finally found, postman send GET request no problem, but post is problematic; Find code find all post return value is void. But this should not affect AH. Thus, the string that all requests are voidis found to be good!!!!!

Process:

In solving the problem, we find that there are two flag bits in the process of sending post

1, is the value of transfer-encoding is chunked, to explain the meaning: Sometimes the service generates an HTTP response is unable to determine the size of the message, such as the download of large files, or the background requires complex logic to fully handle the page request, When the message length is generated in real time, the server typically uses chunked encoding. In the chunked encoded transmission, the headers of the reply message has a transfer-encoding domain value of chunked, indicating that the content will be transmitted in chunked encoding.

2, the content length of thecontent-length representative request

Summarize:

The HTTP protocol is a persistent link in 1.1 cases, but the return value of the post in our program is void, and the request waits for the background to give a return flag bit, but the backend ends after executing the method. (The return method is called by default, why doesn't the framework fall in?) So the request will be reported provisional headers is shown this error. When you add return, you don't get an error.

Workaround: 1) method return value plus return, Flag end. 2) Modify method return header,3) change the HTTP request version inside Nginx.

HTTP protocol version and Java return value discussion

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.