List of usage examples for io.netty.handler.codec.http HttpMethod GET
HttpMethod GET
To view the source code for io.netty.handler.codec.http HttpMethod GET.
Click Source Link
From source file:net.mms_projects.copy_it.api.oauth.HeaderVerifierTest.java
License:Open Source License
@Test(expected = OAuthException.class, timeout = 750) public void missingOAuthVersion() throws OAuthException, URISyntaxException { String header = "OAuth realm=\"\", " + "oauth_consumer_key=\"401a131e03357df2a563fba48f98749448ed63d37e007f7353608cf81fa70a2d\", " + "oauth_nonce=\"" + Utils.generateNonce() + "\", " + "oauth_timestamp=\"" + Long.toString(System.currentTimeMillis() / 1000) + "\", " + "oauth_signature_method=\"HMAC-SHA1\", " + "oauth_token=\"oauth_token\", " + "oauth_signature=\"CBTk%2FvzxEqqr0AvhnVgdWNHuKfw%3D\""; HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://127.0.0.1:8080/"); request.headers().add(AUTHORIZATION, header); new HeaderVerifier(request, new URI(request.getUri())); }
From source file:net.mms_projects.copy_it.api.oauth.HeaderVerifierTest.java
License:Open Source License
@Test(expected = OAuthException.class, timeout = 750) public void invalidOAuthVersion() throws OAuthException, URISyntaxException { String header = "OAuth realm=\"\", " + "oauth_consumer_key=\"401a131e03357df2a563fba48f98749448ed63d37e007f7353608cf81fa70a2d\", " + "oauth_nonce=\"" + Utils.generateNonce() + "\", " + "oauth_timestamp=\"" + Long.toString(System.currentTimeMillis() / 1000) + "\", " + "oauth_signature_method=\"HMAC-SHA1\", " + "oauth_token=\"oauth_token\", " + "oauth_version=\"2.0\", " + "oauth_signature=\"CBTk%2FvzxEqqr0AvhnVgdWNHuKfw%3D\""; HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://127.0.0.1:8080/"); request.headers().add(AUTHORIZATION, header); new HeaderVerifier(request, new URI(request.getUri())); }
From source file:net.mms_projects.copy_it.api.oauth.HeaderVerifierTest.java
License:Open Source License
@Test(expected = OAuthException.class, timeout = 750) public void missingOAuthToken() throws OAuthException, URISyntaxException { String header = "OAuth realm=\"\", " + "oauth_consumer_key=\"401a131e03357df2a563fba48f98749448ed63d37e007f7353608cf81fa70a2d\", " + "oauth_nonce=\"" + Utils.generateNonce() + "\", " + "oauth_timestamp=\"" + Long.toString(System.currentTimeMillis() / 1000) + "\", " + "oauth_signature_method=\"HMAC-SHA1\", " + "oauth_version=\"1.0\", " + "oauth_signature=\"CBTk%2FvzxEqqr0AvhnVgdWNHuKfw%3D\""; HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://127.0.0.1:8080/"); request.headers().add(AUTHORIZATION, header); new HeaderVerifier(request, new URI(request.getUri())); }
From source file:net.mms_projects.copy_it.api.oauth.HeaderVerifierTest.java
License:Open Source License
@Test(expected = OAuthException.class, timeout = 750) public void missingOAuthSignature() throws OAuthException, URISyntaxException { String header = "OAuth realm=\"\", " + "oauth_consumer_key=\"401a131e03357df2a563fba48f98749448ed63d37e007f7353608cf81fa70a2d\", " + "oauth_nonce=\"" + Utils.generateNonce() + "\", " + "oauth_timestamp=\"" + Long.toString(System.currentTimeMillis() / 1000) + "\", " + "oauth_signature_method=\"HMAC-SHA1\", " + "oauth_version=\"1.0\", " + "oauth_token=\"oauth_token\""; HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://127.0.0.1:8080/"); request.headers().add(AUTHORIZATION, header); new HeaderVerifier(request, new URI(request.getUri())); }
From source file:net.mms_projects.copy_it.api.oauth.HeaderVerifierTest.java
License:Open Source License
@Test(expected = OAuthException.class, timeout = 750) public void invalidParameter() throws OAuthException, URISyntaxException { String header = "OAuth realm=\"\", " + "oauth_consumer_key=\"401a131e03357df2a563fba48f98749448ed63d37e007f7353608cf81fa70a2d\", " + "oauth_nonce=\"" + Utils.generateNonce() + "\", " + "oauth_timestamp=\"" + Long.toString(System.currentTimeMillis() / 1000) + "\", " + "oauth_signature_method=\"HMAC-SHA1\", " + "oauth_version=\"1.0\", " + "oauth_token=\"oauth_token\"" + "oauth_signature=\"CBTk%2FvzxEqqr0AvhnVgdWNHuKfw%3D\"" + "i_am_invalid=\"I'm totally fake\""; HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://127.0.0.1:8080/"); request.headers().add(AUTHORIZATION, header); new HeaderVerifier(request, new URI(request.getUri())); }
From source file:net.mms_projects.copy_it.api.oauth.HeaderVerifierTest.java
License:Open Source License
@Test(expected = OAuthException.class, timeout = 750) public void tooLongNonce() throws OAuthException, URISyntaxException { String header = "OAuth realm=\"\", " + "oauth_consumer_key=\"401a131e03357df2a563fba48f98749448ed63d37e007f7353608cf81fa70a2d\", " + "oauth_nonce=\"" + Utils.generateNonce() + Utils.generateNonce() + "\", " + "oauth_timestamp=\"" + Long.toString(System.currentTimeMillis() / 1000) + "\", " + "oauth_signature_method=\"HMAC-SHA1\", " + "oauth_version=\"1.0\", " + "oauth_token=\"oauth_token\"" + "oauth_signature=\"CBTk%2FvzxEqqr0AvhnVgdWNHuKfw%3D\"" + "i_am_invalid=\"I'm totally fake\""; HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://127.0.0.1:8080/"); request.headers().add(AUTHORIZATION, header); new HeaderVerifier(request, new URI(request.getUri())); }
From source file:net.mms_projects.copy_it.api.oauth.HeaderVerifierTest.java
License:Open Source License
@Test(timeout = 750) public void noRealm() throws OAuthException, URISyntaxException { String header = "OAuth oauth_consumer_key=\"401a131e03357df2a563fba48f98749448ed63d37e007f7353608cf81fa70a2d\", " + "oauth_nonce=\"" + Utils.generateNonce() + "\", " + "oauth_timestamp=\"" + Long.toString(System.currentTimeMillis() / 1000) + "\", " + "oauth_signature_method=\"HMAC-SHA1\", " + "oauth_version=\"1.0\", " + "oauth_token=\"oauth_token\", " + "oauth_signature=\"CBTk%2FvzxEqqr0AvhnVgdWNHuKfw%3D\""; HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://127.0.0.1:8080/"); request.headers().add(AUTHORIZATION, header); new HeaderVerifier(request, new URI(request.getUri())); }
From source file:net.mms_projects.copy_it.api.oauth.HeaderVerifierTest.java
License:Open Source License
@Test(timeout = 750) public void validRequest() throws OAuthException, URISyntaxException { String header = "OAuth realm=\"\", " + "oauth_consumer_key=\"401a131e03357df2a563fba48f98749448ed63d37e007f7353608cf81fa70a2d\", " + "oauth_nonce=\"" + Utils.generateNonce() + "\", " + "oauth_timestamp=\"" + Long.toString(System.currentTimeMillis() / 1000) + "\", " + "oauth_signature_method=\"HMAC-SHA1\", " + "oauth_version=\"1.0\", " + "oauth_token=\"oauth_token\", " + "oauth_signature=\"CBTk%2FvzxEqqr0AvhnVgdWNHuKfw%3D\""; HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://127.0.0.1:8080/"); request.headers().add(AUTHORIZATION, header); new HeaderVerifier(request, new URI(request.getUri())); }
From source file:net.nikore.gozer.router.RibbonUtils.java
License:Apache License
public HttpMethod getVerb(HttpServletRequest request) { String method = request.getMethod(); if (method == null) { return HttpMethod.GET; } else {//from w ww .j av a 2 s.c o m return HttpMethod.valueOf(method); } }
From source file:net.oebs.jalos.netty.HttpHandler.java
License:Open Source License
private FullHttpResponse handleRequest(HttpRequest request) { FullHttpResponse response = null;/* www . j a va 2s . c om*/ String uri = request.getUri(); // lookup Handler class by URL Class cls = null; for (Route route : routes) { if (uri.matches(route.path)) { cls = route.handler; break; } } // no matching handler == 404 if (cls == null) { log.info("No handler match found for uri {}", uri); return notFound(); } Handler h; try { h = (Handler) cls.newInstance(); } catch (InstantiationException | IllegalAccessException ex) { return internalError(); } Map<String, String> params = null; HttpMethod method = request.getMethod(); // dispatch based on request method try { if (method.equals(HttpMethod.POST)) { HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(new DefaultHttpDataFactory(false), request); params = httpDataToStringMap(decoder.getBodyHttpDatas()); response = h.handlePost(uri, params); } else if (method.equals(HttpMethod.GET)) { params = new HashMap<>(); response = h.handleGet(uri, params); } else { response = badRequest(); } } catch (BadRequest ex) { response = badRequest(); } catch (NotFound ex) { response = notFound(); } catch (HandlerError ex) { response = internalError(); } return response; }