0

I have a web service that is processed on the Spring end as follows:

    @POST
    @Path("/processRequest")
    @Consumes("multipart/mixed")
    @ResponseStatus(HttpStatus.OK)
    public String processRequest(@Context ServletContext servletContext, MultipartInput input) {

        return addAccout(servletContext, input);
    }

The request will come in as a multipart/mixed request and will look something like this:

--productBoundary
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8"?>
<product>
     <name>ProductA</name>
</product>

--productBoundary
Content-Type: text/xml

ZGF0YRBAAABn5///////////////5///Z+fn///n////////5////////2f//2f//+f//+f////n/
///////52f//////2f//////2f/////5////////+f/////Z+f///////////////9n//9nZ/9n////5+f///9
<snip>
//+f//////2f/////////5//n//////////9n

--productBoundary--

The request will come in as a mutipart/mixed. I can use Resteasy's object shown in the processRequest's method parameters to extract each part of the multipart/mixed message. What i would like to do though is to get the message as it is unmodified with its headers and everything else. Is this possible?

I need to be able to store the request exactly as it came in. Using the MultipartInput structure means i have modified the request. Is there anyway i can get the request as it came in (with all its headers) without modifying it?

skaffman
  • 398,947
  • 96
  • 818
  • 769
ziggy
  • 15,677
  • 67
  • 194
  • 287

1 Answers1

2

Docs here:

3.1.18 @RequestPart Annotation On Controller Method Arguments

This new annotation provides access to the content of a "multipart/form-data" request part. See Section 16.10.5, “Handling a file upload request from programmatic clients” and Section 16.10, “Spring's multipart (file upload) support”.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
rooftop
  • 3,031
  • 1
  • 22
  • 33
  • Thanks - @RequestPart still splits the request. I am interested in the request as a whole so that i can store it - Exactly as it came in with the headers(i.e. boundary, content-type etc) – ziggy May 04 '12 at 13:46
  • This question sums it up: http://stackoverflow.com/questions/3320674/spring-how-do-i-inject-an-httpservletrequest-into-a-request-scoped-bean A way to get the HttpServletRequest, which allows you to get the raw headers. – rooftop May 04 '12 at 14:04