Spring Framework FormHttpMessageConverter - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework FormHttpMessageConverter class.

This code example shows how to use the following methods:
 * 
 * @author Rossen Stoyanchev 
 */ 
public class JsonpReceivingTransportHandler extends AbstractHttpReceivingTransportHandler {
 
	private final FormHttpMessageConverter formConverter = new FormHttpMessageConverter();
 
 
	@Override 
	public TransportType getTransportType() { 
		return TransportType.JSONP_SEND; 
	} 
 
	@Override 
	public void handleRequestInternal(ServerHttpRequest request, ServerHttpResponse response,
			WebSocketHandler wsHandler, AbstractHttpSockJsSession sockJsSession) throws SockJsException {
 
		super.handleRequestInternal(request, response, wsHandler, sockJsSession);
		try { 
			response.getBody().write("ok".getBytes(UTF8_CHARSET));
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
	private final FormHttpMessageConverter delegateMessageConverter;
 
	public FormOAuth2AccessTokenMessageConverter() { 
		super(MediaType.APPLICATION_FORM_URLENCODED, MediaType.TEXT_PLAIN);
		this.delegateMessageConverter = new FormHttpMessageConverter();
	} 
 
	@Override 
	protected boolean supports(Class<?> clazz) {
		return OAuth2AccessToken.class.equals(clazz);
	} 
 
	@Override 
	protected OAuth2AccessToken readInternal(Class<? extends OAuth2AccessToken> clazz, HttpInputMessage inputMessage)
			throws IOException, HttpMessageNotReadableException {
		MultiValueMap<String, String> data = delegateMessageConverter.read(null, inputMessage);
		return DefaultOAuth2AccessToken.valueOf(data.toSingleValueMap());
	} 
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    assertThat(list(wrapper.getParameterNames()), hasItems("param1", "param2"));
    assertThat(wrapper.getParameterValues("param1"), is(new String[] {"value1", "value3"}));
  } 
 
  private FormEncodedHttpServletRequestWrapper wrap(MockHttpServletRequest request) {
    return new FormEncodedHttpServletRequestWrapper(request, new FormHttpMessageConverter());
  } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 */ 
public final class FormOAuth2ExceptionHttpMessageConverter implements HttpMessageConverter<OAuth2Exception> {
 
	private static final List<MediaType> SUPPORTED_MEDIA = Collections.singletonList(MediaType.APPLICATION_FORM_URLENCODED);
 
	private final FormHttpMessageConverter delegateMessageConverter = new FormHttpMessageConverter();
 
	public boolean canRead(Class<?> clazz, MediaType mediaType) {
		return OAuth2Exception.class.equals(clazz) && MediaType.APPLICATION_FORM_URLENCODED.equals(mediaType);
	} 
 
	public boolean canWrite(Class<?> clazz, MediaType mediaType) {
		return OAuth2Exception.class.equals(clazz) && MediaType.APPLICATION_FORM_URLENCODED.equals(mediaType);
	} 
 
	public List<MediaType> getSupportedMediaTypes() {
		return SUPPORTED_MEDIA;
	} 
 
	public OAuth2Exception read(Class<? extends OAuth2Exception> clazz, HttpInputMessage inputMessage)
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
@Component 
public class FormEncodedContentTypeFilter extends OncePerRequestFilter { 
  private final FormHttpMessageConverter messageConverter; 
 
  public FormEncodedContentTypeFilter() { 
    this.messageConverter = new FormHttpMessageConverter(); 
  } 
 
  @Override 
  protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) 
                           throws ServletException, IOException { 
    if (isPost(request) && isContentTypeNotSet(request)) { 
      request = new FormEncodedHttpServletRequestWrapper(request, messageConverter); 
    } 
    chain.doFilter(request, response); 
  } 
 
  private boolean isContentTypeNotSet(HttpServletRequest request) { 
    return isBlank(request.getHeader("Content-Type")); 
  } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setCharset, setPartConverters
	 * By default, the message converter is set to use "UTF-8" character encoding. 
	 * Override to customize the message converter (for example, to set supported media types or message converters for the parts of a multipart message).  
	 * To remove/replace this or any of the other message converters that are registered by default, override the getMessageConverters() method instead. 
	 */ 
	protected FormHttpMessageConverter getFormMessageConverter() {
		FormHttpMessageConverter converter = new FormHttpMessageConverter();
		converter.setCharset(Charset.forName("UTF-8"));
		List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
		partConverters.add(new ByteArrayHttpMessageConverter());
		StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
		stringHttpMessageConverter.setWriteAcceptCharset(false);
		partConverters.add(stringHttpMessageConverter);
		partConverters.add(new ResourceHttpMessageConverter());		
		converter.setPartConverters(partConverters);
		return converter;
	} 
	 
	/** 
	 * Returns a {@link MappingJackson2HttpMessageConverter} to be used by the internal {@link RestTemplate}. 
	 * Override to customize the message converter (for example, to set a custom object mapper or supported media types). 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setCharset, setPartConverters
	 * By default, the message converter is set to use "UTF-8" character encoding. 
	 * Override to customize the message converter (for example, to set supported media types or message converters for the parts of a multipart message).  
	 * To remove/replace this or any of the other message converters that are registered by default, override the getMessageConverters() method instead. 
	 */ 
	protected FormHttpMessageConverter getFormMessageConverter() {
		FormHttpMessageConverter converter = new FormHttpMessageConverter();
		converter.setCharset(Charset.forName("UTF-8"));
		List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
		partConverters.add(new ByteArrayHttpMessageConverter());
		StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
		stringHttpMessageConverter.setWriteAcceptCharset(false);
		partConverters.add(stringHttpMessageConverter);
		partConverters.add(new ResourceHttpMessageConverter());		
		converter.setPartConverters(partConverters);
		return converter;
	} 
 
	/** 
	 * Returns a {@link MappingJackson2HttpMessageConverter} to be used by the internal {@link RestTemplate}. 
	 * Override to customize the message converter (for example, to set a custom object mapper or supported media types). 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
package org.cloudfoundry.client.lib.rest; 
 
import org.cloudfoundry.client.lib.domain.UploadApplicationPayload; 
import org.springframework.http.converter.FormHttpMessageConverter; 
 
public class CloudFoundryFormHttpMessageConverter extends FormHttpMessageConverter { 
	@Override 
	protected String getFilename(Object part) { 
		if (part instanceof UploadApplicationPayload) { 
			return ((UploadApplicationPayload) part).getArchive().getFilename(); 
		} 
		return super.getFilename(part); 
	} 
} 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        Strategy strategy = new RegistryStrategy(registry);
        Serializer serializer = new Persister(strategy);
        xmlConverter.setSerializer(serializer);
        messageConverters.add(xmlConverter);
        messageConverters.add(new StringHttpMessageConverter());
        messageConverters.add(new FormHttpMessageConverter());
        template.setRequestFactory(requestFactory);
        template.setMessageConverters(messageConverters);
    } 
 
    protected static org.apache.http.conn.ssl.SSLSocketFactory createAdditionalCertsSSLSocketFactory(Context context) {
        try { 
            final KeyStore ks = KeyStore.getInstance("BKS");
 
            // keystore with root certificate in bks format 
            final InputStream in = context.getResources().openRawResource(R.raw.keystore);
            try { 
                ks.load(in, "password".toCharArray());
            } finally { 
                in.close();
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
package org.cloudfoundry.client.lib.util; 
 
import static org.apache.http.conn.ssl.SSLSocketFactory.STRICT_HOSTNAME_VERIFIER;
 
import java.net.URL;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
 
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.HttpClient;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy; 
import org.apache.http.impl.client.DefaultHttpClient;
import org.cloudfoundry.client.lib.HttpProxyConfiguration; 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Spring Framework FormHttpMessageConverter Methods: