Search in sources :

Example 1 with AcceptType

use of com.webpieces.http2.api.subparsers.AcceptType in project webpieces by deanhiller.

the class RouterServiceImpl method parseAccept.

private void parseAccept(Http2Headers req, RouterRequest routerRequest) {
    List<AcceptType> types = headerParser.parseAcceptFromRequest(req);
    List<AcceptMediaType> acceptedTypes = new ArrayList<>();
    for (AcceptType t : types) {
        if (t.isMatchesAllTypes())
            acceptedTypes.add(new AcceptMediaType());
        else if (t.isMatchesAllSubtypes())
            acceptedTypes.add(new AcceptMediaType(t.getMainType()));
        else
            acceptedTypes.add(new AcceptMediaType(t.getMainType(), t.getSubType()));
    }
    routerRequest.acceptedTypes = acceptedTypes;
}
Also used : ArrayList(java.util.ArrayList) AcceptType(com.webpieces.http2.api.subparsers.AcceptType) AcceptMediaType(org.webpieces.ctx.api.AcceptMediaType)

Aggregations

AcceptType (com.webpieces.http2.api.subparsers.AcceptType)1 ArrayList (java.util.ArrayList)1 AcceptMediaType (org.webpieces.ctx.api.AcceptMediaType)1