class MultivaluedMapEntityProvider implements EntityProvider<MultivaluedMap<String, String>> {

    @Override
    public void writeTo(MultivaluedMap<String, String> multivaluedMap,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream) throws IOException {
        int i = 0;
        for (Map.Entry<String, List<String>> e : multivaluedMap.entrySet()) {
            for (String value : e.getValue()) {
                if (i > 0) {
                    entityStream.write('&');
                }
                String name = URLEncoder.encode(e.getKey(), "UTF-8");
                entityStream.write(name.getBytes());
                i++;
                if (value != null) {
                    entityStream.write('=');
                    value = URLEncoder.encode(value, "UTF-8");
                    entityStream.write(value.getBytes());
                }
            }
        }
    }

    public  MultivaluedMapEntityProvider(@Context HttpServletRequest httpRequest);

}