Java Code Examples for org.jboss.netty.handler.codec.http.HttpRequest#getMethod()

The following examples show how to use org.jboss.netty.handler.codec.http.HttpRequest#getMethod() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RaopAudioHandler.java    From Android-Airplay-Server with MIT License 5 votes vote down vote up
@Override
public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent evt) throws Exception {
	final HttpRequest req = (HttpRequest)evt.getMessage();
	final HttpMethod method = req.getMethod();

	LOG.info("messageReceived : HttpMethod: " + method);
	
	if (RaopRtspMethods.ANNOUNCE.equals(method)) {
		announceReceived(ctx, req);
		return;
	}
	else if (RaopRtspMethods.SETUP.equals(method)) {
		setupReceived(ctx, req);
		return;
	}
	else if (RaopRtspMethods.RECORD.equals(method)) {
		recordReceived(ctx, req);
		return;
	}
	else if (RaopRtspMethods.FLUSH.equals(method)) {
		flushReceived(ctx, req);
		return;
	}
	else if (RaopRtspMethods.TEARDOWN.equals(method)) {
		teardownReceived(ctx, req);
		return;
	}
	else if (RaopRtspMethods.SET_PARAMETER.equals(method)) {
		setParameterReceived(ctx, req);
		return;
	}
	else if (RaopRtspMethods.GET_PARAMETER.equals(method)) {
		getParameterReceived(ctx, req);
		return;
	}

	super.messageReceived(ctx, evt);
}
 
Example 2
Source File: HttpServerRequestHandler.java    From feeyo-hlsserver with Apache License 2.0 4 votes vote down vote up
private IRequestHandler getHandler(HttpRequest request) {
  	
  	IRequestHandler handler = null;
  	
  	//解析QueryString    	
String uriString = request.getUri();

//获取Path
String path = null;
  	int pathEndPos = uriString.indexOf('?');
if (pathEndPos < 0) {
	path = uriString;
} else {
	path = uriString.substring(0, pathEndPos);	
}

// 获取参数
Map<String, String> parameters = new HashMap<String, String>();
if (uriString.startsWith("?")) {
	uriString = uriString.substring(1, uriString.length());
}
String[] querys = uriString.split("&");
for (String query : querys) {
	String[] pair = query.split("=");
	if (pair.length == 2) {								
		try {
			parameters.put(URLDecoder.decode(pair[0], "UTF8"), URLDecoder.decode(pair[1],"UTF8"));
		} catch (UnsupportedEncodingException e) {
			parameters.put(pair[0], pair[1]);
		}
	}
}

      HttpMethod method = request.getMethod();
      if (method == HttpMethod.GET) {
      	handler = getHandlers.retrieve(path, parameters);
      	
      } else if (method == HttpMethod.POST) {
          	handler = postHandlers.retrieve(path, parameters);
      } 
      return handler;
  }