RestTemplate, PUT method, and Expect: 100-CONTINUE
I'm a newbie to resttemplate and how it is backed by Apache http classes. So at first I thought all I needed to do was manually create http headers with Expect: 100 Continue in order to start implementing a PUT method using that feature. In my case the server with which I was having a dialogue responded correctly but my application never saw the 100-Continue response because the 100-Continue is being ignored, as such: [org.apache.commons.httpclient.HttpMethodBase] - <'Discarding unexpected response: HTTP/1.1 100 Continue>. Wireshark confirms I got the 100 Continue.
I understand now after doing some reading that somewhere I must set the default behavior of the PUT method to use the Expect: 100-Continue header...and I'm starting to think its nowhere in any Springsource authored class. As far as I can tell the relevant Apache abstract class is: org.apache.commons.httpclient.methods.ExpectContinueMethod, which has a sublclass called org开发者_开发问答.apache.commons.httpclient.methods.PutMethod, and in any event has a setter for using Expect: 100-CONTINUE in all PUT requests.
So this leads to 2 questions now, now 1.
How can I set this feature so I can use 100-CONTINUE in my dialogues with servers? I've been searching within Springsource documentation and I see where the HttpClientParams are set and how for the CommonsClientHttpRequestFactory, but I'm at a loss of where or how to set the use of ExpectContinueMethod when resttemplate acts on a PUT request. I'm starting to think it is not possible from within any Springsource class or package...I'm getting the feeling resttemplate is just too high level, so to speak.
Perhaps I have to import many Apache packages just to instantiate them and specify the use of the ExpectContinue feature, and somehow make sure resttemplate and other Springsource classes use them (if that is even possible or makes sense). Today that's over my head but I have a vague notion of what needs to be done. Even if true, does this mean that for any application I must choose to either use the 100-Continue header for all PUT requests forever? I cannot have some PUT requests use it and others not depending on, say, the size of the body? This would be terrible.
Even a pointer in the correct direction would be appreciated.
-Paul
精彩评论