के साथ "अपेक्षा: 100-जारी रखें" शीर्षलेख का समर्थन करना मैं एएसपी.नेट एमवीसी का उपयोग कर एक आरईएसटी एपीआई लागू कर रहा हूं, औरअनुरोध हेडर के अनुरोध के साथ थोड़ा स्टम्बलिंग ब्लॉक आया है एक पोस्ट बॉडीएएसपी.नेट एमवीसी
RFC 2616 कहा गया है कि:
Upon receiving a request which includes an Expect request-header field with the "100-continue" expectation, an origin server MUST either respond with 100 (Continue) status and continue to read from the input stream, or respond with a final status code. The origin server MUST NOT wait for the request body before sending the 100 (Continue) response. If it responds with a final status code, it MAY close the transport connection or it MAY continue to read and discard the rest of the request. It MUST NOT perform the requested method if it returns a final status code.
यह मेरे लिए लग रहा है जैसे मैं से पढ़ना जारी अनुरोध करने के लिए दो प्रतिक्रियाओं बनाने की जरूरत है, यानी इसे तुरंत भेजने के लिए एक HTTP 100 प्रतिक्रिया जारी की जरूरत है, और उसके बाद मूल अनुरोध धारा (यानी HttpContext.Request.InputStream
) अनुरोध समाप्त किए बिना, और अंततः परिणामी स्थिति कोड भेजना (तर्क के लिए, मान लें कि यह 204 कोई सामग्री परिणाम नहीं है)।
तो, सवाल कर रहे हैं:
- एम आई विनिर्देश सही पढ़ना, कि मैं एक अनुरोध करने के लिए दो प्रतिक्रियाओं बनाने की जरूरत है?
- यह एएसपी.नेट एमवीसी में कैसे किया जा सकता है?
w.r.t. (2) मैं इनपुट धारा को पढ़ने के लिए आगे बढ़ने से पहले निम्नलिखित कोड का उपयोग कर की कोशिश की है ...
HttpContext.Response.StatusCode = 100;
HttpContext.Response.Flush();
HttpContext.Response.Clear();
... लेकिन जब मैं अंतिम 204 स्थिति कोड सेट करने का प्रयास मैं त्रुटि मिलती है:
System.Web.HttpException: Server cannot set status after HTTP headers have been sent.
नहीं - मैं इससे बचना चाहता हूं! मुझे एहसास नहीं हुआ कि आईआईएस बिना किसी हस्तक्षेप के इसे संभालेगा। –
मुझे 100 वेब जारी रखने के साथ 'WebRequest' में एक बग का सामना करना पड़ा है। इसका उपयोग न करने का एक अच्छा कारण है। http://regis.decamps.info/blog/2010/12/c-bug-in-webrequest/ – rds