How can I modify a POST request using a custom IHttpModule and an HttpRequest filter?

后端 未结 3 1182
你的背包
你的背包 2020-12-18 10:10

Overview

I want to be able to modify request parameters and content to 3rd party web services (ArcGIS Server). This will be used to create a securit

3条回答
  •  臣服心动
    2020-12-18 10:43

    This question and your answer were really useful for me, however the answer is not the whole story if you're trying to insert larger amounts of data into the stream:

    Returning the modified content size is only valid if the data you're inserting into the stream will not take the number of bytes read into the buffer over the count value. If you try to insert too much data, you're either going to find that the buffer object isn't large enough to hold the data you're inserting, or that by writing more than count bytes to the buffer, you're overwriting some data at the end of the buffer that was meant to be left alone.

    If you need to insert more data than the current buffer object can accommodate then you'll have to buffer the data in a separate byte array and copy it in chunks as the calls to stream.read are made.

提交回复
热议问题