This article is a mirror article of machine translation, please click here to jump to the original article.

View: 34067|Reply: 1

[Source] The HttpListener writes bytes to the stream beyond the specified Content-Length byte size

[Copy link]
Posted on 4/29/2019 2:43:39 PM | | | |
System.Net.ProtocolViolationException: 写入流的字节超出指定的 Content-Length 字节大小。

HttpListener responds to the exception thrown by the request, but I don't know what caused it, the original code is as follows:

No errors were found, the local debugging was normal, and the output request method and path were as follows:



The discovery request type is “HEAD”The way is as follows:

HEAD is like GET, except that the server only returns the response header after receiving the HEAD request, and does not send the response content. When we only need to check the status of a page, using HEAD is very efficient because the page content is omitted during the transmission process.
That is, after the user requests through the head method, the server cannot return the corresponding content, so add judgment to the switch, the code is as follows:

Everything is fine, as shown below:






Previous:Is it really necessary to remove whitespace characters from HTML?
Next:The timeout has expired, but the connection has not yet been taken from the pool.
Posted on 3/8/2022 11:27:24 AM |
Just encountered the same problem
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com