public
Last active

RESTful Web Service Discoverability with Spring MVC 3.1, part 4 - the HTTP Header utils

  • Download Gist
HTTPHeaderUtils.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
public static List< String > parseLinkHeader( String linkHeader ){
Preconditions.checkNotNull( linkHeader );
List< String > linkHeaders = Lists.newArrayList();
String[] links = linkHeader.split( ", " );
for( final String link : links ){
int positionOfSeparator = link.indexOf( ';' );
linkHeaders.add( link.substring( 1, positionOfSeparator - 1 ) );
}
return linkHeaders;
}
public static String parseSingleLinkHeader( String linkHeader ){
Preconditions.checkNotNull( linkHeader );
int positionOfSeparator = linkHeader.indexOf( ';' );
return linkHeader.substring( 1, positionOfSeparator - 1 );
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.