Set the http request properties and headers.

@param cl
The received command line
@param method
The HTTP method
@return Properties
@throws UnsupportedEncodingException
558290
private Properties getRequestProperties(final ICommandLine cl, final String method) throws UnsupportedEncodingException {
        Properties props = new Properties();
        if (cl.hasOption("useragent")) {
            props.setProperty("User-Agent", cl.getOptionValue("useragent"));
        } else {
            props.setProperty("User-Agent", DEFAULT_USER_AGENT);
        }
        if (cl.hasOption("content-type") && "POST".equalsIgnoreCase(method)) {
            props.setProperty("Content-Type", cl.getOptionValue("content-type"));
        }
        if (cl.hasOption("header")) {
            List headers = cl.getOptionValues("header");
            for (Object obj : headers) {
                String header = (String) obj;
                String key = header.split(":")[0].trim();
                String value = header.split(":")[1].trim();
                props.setProperty(key, value);
            }
        }
        String auth = null;
        String encoded = null;
        if (cl.hasOption("authorization")) {
            encoded = Base64.encodeBase64String(cl.getOptionValue("authorization").getBytes(CHARSET));
            auth = "Authorization";
        } else if (cl.hasOption("proxy-authorization")) {
            encoded = Base64.encodeBase64String(cl.getOptionValue("proxy-authorization").getBytes(CHARSET));
            auth = "Proxy-Authorization";
        }
        if (auth != null && encoded != null) {
            props.setProperty(auth, "Basic " + encoded);
        }
        return props;
    }
934108
private static Set<Annotation> httpMethodAnnotations(Method method) {
        return getAnnotations(method, FindOption.LOOKUP_SUPER_CLASSES)
                .stream()
                .filter(annotation -> HTTP_METHOD_MAP.containsKey(annotation.annotationType()))
                .collect(Collectors.toSet());
    }
1263640
public SipServletRequest createRequest(final String method) {
		if(logger.isDebugEnabled()) {
			logger.debug("createRequest - method="+ method);
			logger.debug("createRequest - getId()="+ getId());
		}
		if(method.equalsIgnoreCase(Request.ACK) || method.equalsIgnoreCase(Request.PRACK)
				|| method.equalsIgnoreCase(Request.CANCEL)) {
			throw new IllegalArgumentException(
					"Can not create ACK, PRACK or CANCEL requests with this method");
		}
		if(!isValid()) {
			throw new IllegalStateException("cannot create a subsequent request " + method + " because the session " + key + " is invalid");
		}
		if(State.TERMINATED.equals(state)) {
			throw new IllegalStateException("cannot create a subsequent request " + method + " because the session " + key + " is in TERMINATED state");
		}
		// Issue 2440 : http://code.google.com/p/mobicents/issues/detail?id=2440
		// SipSession.createRequest on proxy SipSession does not throw IllegalStateException
		if(proxy != null) {
			throw new IllegalStateException("cannot create a subsequent request " + method + " because the session " + key + " has been used for proxying. See JSR289 Section 6.2.2.1.");
		}
//		if((State.INITIAL.equals(state) && hasOngoingTransaction())) {
//			throw new IllegalStateException("cannot create a request because the session is in INITIAL state with ongoing transactions");
//		}
		if(logger.isDebugEnabled()) {
			logger.debug("dialog associated with this session to create the new request " + method + " within that dialog "+
					sessionCreatingDialog);
			if(sessionCreatingDialog != null) {
				logger.debug("dialog state " + sessionCreatingDialog.getState() + " for that dialog "+ sessionCreatingDialog);
			}
		}
		SipServletRequestImpl sipServletRequest = null;
		// Fix for Issue http://code.google.com/p/mobicents/issues/detail?id=2230 BYE is routed to unexpected IP
		// MSS should throw an IllegalStateException when a subsequent request is being created on a TERMINATED dialog
		// don't do it on the BYE method as a 408 within a dialog could have make the dialog TERMINATED and MSS should allow the app to create the subsequent BYE from any thread
		if(sessionCreatingDialog != null && DialogState.TERMINATED.equals(sessionCreatingDialog.getState()) && !method.equalsIgnoreCase(Request.BYE)) {
			// don't do it for authentication as the dialog will go back to TERMINATED state, so we should allow to create challenge requests
			if(sessionCreatingTransactionRequest == null || sessionCreatingTransactionRequest.getLastFinalResponse() == null ||
					(sessionCreatingTransactionRequest.getLastFinalResponse().getStatus() != 401 && sessionCreatingTransactionRequest.getLastFinalResponse().getStatus() != 407 &&
						// http://code.google.com/p/sipservlets/issues/detail?id=143 RFC 4028 Session Timer : Allow sending retry INVITE after receiving 422 response
						sessionCreatingTransactionRequest.getLastFinalResponse().getStatus() != SipServletResponse.SC_SESSION_INTERVAL_TOO_SMALL)) {
				throw new IllegalStateException("cannot create a subsequent request " + method + " because the dialog " + sessionCreatingDialog + " for session " + key + " is in TERMINATED state");
			}
		}
		// Issue http://code.google.com/p/mobicents/issues/detail?id=2230 BYE is routed to unexpected IP BYE can be sent on a TERMINATED Dialog
		if(this.sessionCreatingDialog != null &&
				(!DialogState.TERMINATED.equals(sessionCreatingDialog.getState()) ||
						(DialogState.TERMINATED.equals(sessionCreatingDialog.getState()) && method.equalsIgnoreCase(Request.BYE)))) {

			if(logger.isDebugEnabled()) {
				logger.debug("dialog " + sessionCreatingDialog + " used to create the new request " + method);
			}
			try {
				final Request methodRequest = this.sessionCreatingDialog.createRequest(method);

				if(methodRequest.getHeader(ContactHeader.NAME) != null) {
					// if a sip load balancer is present in front of the server, the contact header is the one from the sip lb
					// so that the subsequent requests can be failed over
					try {
						ContactHeader contactHeader = null;
						FromHeader from = (FromHeader) methodRequest.getHeader(FromHeader.NAME);
						String displayName = from.getAddress().getDisplayName();
						String userName = null;
						javax.sip.address.URI uri = from.getAddress().getURI();
						if(uri.isSipURI()) {
							userName = ((javax.sip.address.SipURI)uri).getUser();
						}
						if(sipFactory.isUseLoadBalancer()) {
							// https://github.com/RestComm/sip-servlets/issues/111
							MobicentsExtendedListeningPoint listeningPoint = JainSipUtils.findListeningPoint(sipFactory.getSipNetworkInterfaceManager(), methodRequest, outboundInterface);
							if(listeningPoint != null && listeningPoint.isUseLoadBalancer()) {
								// https://github.com/RestComm/sip-servlets/issues/137
								SipLoadBalancer loadBalancerToUse = null;
								if(listeningPoint.getLoadBalancer() == null) {
									loadBalancerToUse = sipFactory.getLoadBalancerToUse();
									if(logger.isDebugEnabled()) {
										logger.debug("Using listeningPoint " + listeningPoint + " for global load balancer " + sipFactory.getLoadBalancerToUse());
									}
								} else {
									loadBalancerToUse = listeningPoint.getLoadBalancer();
									if(logger.isDebugEnabled()) {
										logger.debug("Using listeningPoint " + listeningPoint + " for connector specific load balancer " + listeningPoint.getLoadBalancer());
									}
								}

								javax.sip.address.SipURI sipURI = SipFactoryImpl.addressFactory.createSipURI(userName, loadBalancerToUse.getAddress().getHostAddress());
								sipURI.setHost(loadBalancerToUse.getAddress().getHostAddress());
								sipURI.setPort(loadBalancerToUse.getSipPort());

								// TODO: Is this enough or we must specify the transport somewhere?
								// We can leave it like this. It will be updated if needed in the send() method
								sipURI.setTransportParam(ListeningPoint.UDP);

								javax.sip.address.Address contactAddress = SipFactoryImpl.addressFactory.createAddress(sipURI);
								contactHeader = SipFactoryImpl.headerFactory.createContactHeader(contactAddress);
							} else {
								if(logger.isDebugEnabled()) {
									logger.debug("Not Using load balancer as it is not enabled for listeningPoint " + listeningPoint);
								}
								contactHeader = JainSipUtils.createContactHeader(sipFactory.getSipNetworkInterfaceManager(), methodRequest, displayName, userName, outboundInterface);
							}
						} else {
							contactHeader = JainSipUtils.createContactHeader(sipFactory.getSipNetworkInterfaceManager(), methodRequest, displayName, userName, outboundInterface);
						}
						methodRequest.setHeader(contactHeader);
					} catch (Exception e) {
						logger.error("Can not create contact header for subsequent request " + method + " for session " + key, e);
					}
				}
				// Fix for Issue 1130 (http://code.google.com/p/mobicents/issues/detail?id=1130) :
				// NullPointerException when sending request to client which support both UDP and TCP transport
				// before removing the via header we store the transport into its app data
				ListIterator<ViaHeader> viaHeaders = methodRequest.getHeaders(ViaHeader.NAME);
				if(viaHeaders != null && viaHeaders.hasNext()) {
					ViaHeader viaHeader = viaHeaders.next();
					((MessageExt)methodRequest).setApplicationData(viaHeader.getTransport());
				}
				//Issue 112 fix by folsson
				methodRequest.removeHeader(ViaHeader.NAME);

				// cater to http://code.google.com/p/sipservlets/issues/detail?id=31 to be able to set the rport in applications
				final SipApplicationDispatcher sipApplicationDispatcher = sipFactory.getSipApplicationDispatcher();
				final String branch = JainSipUtils.createBranch(getSipApplicationSession().getKey().getId(),  sipApplicationDispatcher.getHashFromApplicationName(getKey().getApplicationName()));
				ViaHeader viaHeader = JainSipUtils.createViaHeader(
	    				sipFactory.getSipNetworkInterfaceManager(), methodRequest, branch, outboundInterface);
				methodRequest.addHeader(viaHeader);

				//if a SUBSCRIBE or BYE is sent for exemple, it will reuse the prexisiting dialog
				sipServletRequest = (SipServletRequestImpl) sipFactory.getMobicentsSipServletMessageFactory().createSipServletRequest(
						methodRequest, this, null, sessionCreatingDialog,
						false);
			} catch (SipException e) {
				logger.error("Cannot create the " + method + " request from the dialog " + sessionCreatingDialog,e);
				throw new IllegalArgumentException("Cannot create the " + method + " request from the dialog " + sessionCreatingDialog + " for sip session " + key,e);
			}
		} else {
			boolean treatAsInitialRequest = false;
			// http://code.google.com/p/sipservlets/issues/detail?id=19
			// Retried Request are not considered as initial
			if(sessionCreatingTransactionRequest != null && sessionCreatingTransactionRequest.getLastFinalResponse() != null &&
					sessionCreatingTransactionRequest.getLastFinalResponse().getStatus() >= 400 && sessionCreatingTransactionRequest.getLastFinalResponse().getStatus() < 500) {
				if(logger.isDebugEnabled()) {
					logger.debug("Treating as Initial Request");
				}
				treatAsInitialRequest = true;
			}
			//case where other requests are sent with the same session like REGISTER or for challenge requests
			if(sessionCreatingTransactionRequest != null) {
				if(logger.isDebugEnabled()) {
					logger.debug("createRequest - sessionCreatingTransactionRequest is not null - id:" + this.getId());
				}

				if(!isSessionCreatingTransactionServer) {
					if(logger.isDebugEnabled()) {
						logger.debug("orignal tx for creating susbequent request " + method + " on session " + key +" was a Client Tx");
					}
					Request request = (Request) sessionCreatingTransactionRequest.getMessage().clone();
					// Issue 1524 :	Caused by: java.text.ParseException: CSEQ method mismatch with Request-Line
					javax.sip.address.URI requestUri = (javax.sip.address.URI) request.getRequestURI().clone();
					try {
						request.setMethod(method);
					} catch (ParseException e) {
						throw new IllegalArgumentException("Unexpected exception happened on setting method " + method, e);
					}
					request.setRequestURI(requestUri);
					((MessageExt)request).setApplicationData(null);

					final CSeqHeader cSeqHeader = (CSeqHeader) request.getHeader((CSeqHeader.NAME));
					try {
						cSeqHeader.setSeqNumber(cSeqHeader.getSeqNumber() + 1l);
						cSeqHeader.setMethod(method);
					} catch (InvalidArgumentException e) {
						logger.error("Cannot increment the Cseq header to the new " + method + " on the susbequent request to create on session " + key,e);
						throw new IllegalArgumentException("Cannot create the " + method + " on the susbequent request to create on session " + key,e);
					} catch (ParseException e) {
						throw new IllegalArgumentException("Cannot set the " + method + " on the susbequent request to create on session " + key,e);
					}
					// Fix for Issue 1130 (http://code.google.com/p/mobicents/issues/detail?id=1130) :
					// NullPointerException when sending request to client which support both UDP and TCP transport
					// before removing the ViaHeader we store the transport into its app data
					ListIterator<ViaHeader> viaHeaders = request.getHeaders(ViaHeader.NAME);
					if(viaHeaders != null && viaHeaders.hasNext()) {
						ViaHeader viaHeader = viaHeaders.next();
						((MessageExt)request).setApplicationData(viaHeader.getTransport());
					}
					request.removeHeader(ViaHeader.NAME);

					final SipNetworkInterfaceManager sipNetworkInterfaceManager = sipFactory.getSipNetworkInterfaceManager();
					final SipProvider sipProvider = sipNetworkInterfaceManager.findMatchingListeningPoint(
							JainSipUtils.findTransport(request), false).getSipProvider();
					final SipApplicationDispatcher sipApplicationDispatcher = sipFactory.getSipApplicationDispatcher();
					final String branch = JainSipUtils.createBranch(getSipApplicationSession().getKey().getId(),  sipApplicationDispatcher.getHashFromApplicationName(getKey().getApplicationName()));

					ViaHeader viaHeader = JainSipUtils.createViaHeader(
		    				sipNetworkInterfaceManager, request, branch, outboundInterface);
		    		request.addHeader(viaHeader);

		    		// https://code.google.com/p/sipservlets/issues/detail?id=278
		    		request.removeContent();
		    		// http://code.google.com/p/sipservlets/issues/detail?id=161
		    		// Don't reuse the dialog for challenge requests as it can lead to the JAIN SIP Stack
		    		// reusing the Terminated dialog and drop 200 OK
		    		Dialog dialogToUse = sessionCreatingDialog;
		    		if(treatAsInitialRequest) {
		    			dialogToUse = null;
		    		}

					sipServletRequest = (SipServletRequestImpl) sipFactory.getMobicentsSipServletMessageFactory().createSipServletRequest(
							request, this, null, dialogToUse,
							true);

					// Fix for Issue http://code.google.com/p/mobicents/issues/detail?id=2230 BYE is routed to unexpected IP
					if(sessionCreatingDialog != null && sessionCreatingDialog.getRemoteTarget() != null) {
						SipUri sipUri = (SipUri) sessionCreatingDialog.getRemoteTarget().getURI().clone();
						sipUri.clearUriParms();
						if(logger.isDebugEnabled()) {
							logger.debug("setting request uri to " + sipUri);
						}
						request.setRequestURI(sipUri);
					}
					// http://code.google.com/p/sipservlets/issues/detail?id=130
					// removes the Route and Path Headers added previously for requests that the container originated
					// when the Load Balancer is used to avoid adding them again with each request going out.
					request.removeHeader(RouteHeader.NAME);
					request.removeHeader(PathHeader.NAME);
				} else {
					if(logger.isDebugEnabled()) {
						logger.debug("orignal tx for creating susbequent request " + method + " on session " + key +" was a Server Tx");
					}
					try {
						// copying original params and call id
						final Request originalRequest = (Request) sessionCreatingTransactionRequest.getMessage();
						final FromHeader fromHeader = (FromHeader) originalRequest.getHeader(FromHeader.NAME);
						final ToHeader toHeader = (ToHeader) originalRequest.getHeader(ToHeader.NAME);
						final AddressImpl currentLocalParty = (AddressImpl)this.getLocalParty().clone();
						final AddressImpl currentRemoteParty = (AddressImpl)this.getRemoteParty().clone();
						((Parameters)currentRemoteParty .getAddress().getURI()).removeParameter("tag");
						((Parameters)currentLocalParty .getAddress().getURI()).removeParameter("tag");
						final String originalCallId = ((CallIdHeader)originalRequest.getHeader(CallIdHeader.NAME)).getCallId();
						sipServletRequest =(SipServletRequestImpl) sipFactory.createRequest(
							getSipApplicationSession(),
							method,
							currentLocalParty,
							currentRemoteParty,
							handlerServlet,
							originalCallId,
							fromHeader.getTag());
						final Request request = ((Request)sipServletRequest.getMessage());
						sipServletRequest.getSipSession().setCseq(((CSeqHeader)request.getHeader(CSeqHeader.NAME)).getSeqNumber());
						final Map<String, String> fromParameters = new HashMap<String, String>();
						final Iterator<String> fromParameterNames = fromHeader.getParameterNames();
						while (fromParameterNames.hasNext()) {
							String parameterName = (String) fromParameterNames.next();
							if(sessionCreatingDialog != null || !SipFactoryImpl.FORBIDDEN_PARAMS.contains(parameterName)) {
								fromParameters.put(parameterName, fromHeader.getParameter(parameterName));
							}
						}
						final Map<String, String> toParameters = new HashMap<String, String>();
						final Iterator<String> toParameterNames = toHeader.getParameterNames();
						while (toParameterNames.hasNext()) {
							String parameterName = (String) toParameterNames.next();
							if(sessionCreatingDialog != null || !SipFactoryImpl.FORBIDDEN_PARAMS.contains(parameterName)) {
								toParameters.put(parameterName, toHeader.getParameter(parameterName));
							}
						}

						final ToHeader newTo = (ToHeader) request.getHeader(ToHeader.NAME);
						for (Entry<String, String> fromParameter : fromParameters.entrySet()) {
							String value = fromParameter.getValue();
							if(value == null) {
								value = "";
							}
							newTo.setParameter(fromParameter.getKey(),  value);
						}
						final FromHeader newFrom = (FromHeader) request.getHeader(FromHeader.NAME);
						for (Entry<String, String> toParameter : toParameters.entrySet()) {
							String value = toParameter.getValue();
							if(value == null) {
								value = "";
							}
							newFrom.setParameter(toParameter.getKey(),  value);
						}
						// Fix for Issue http://code.google.com/p/mobicents/issues/detail?id=2230 BYE is routed to unexpected IP
						if(sessionCreatingDialog != null && sessionCreatingDialog.getRemoteTarget() != null) {
							SipUri sipUri = (SipUri) sessionCreatingDialog.getRemoteTarget().getURI().clone();
							sipUri.clearUriParms();
							if(logger.isDebugEnabled()) {
								logger.debug("setting request uri to " + sipUri);
							}
							request.setRequestURI(sipUri);
						}
					} catch (ParseException e) {
						throw new IllegalArgumentException("Problem setting param on the newly created susbequent request " + sipServletRequest,e);
					}
				}

				if(sipSessionSecurity != null && sipSessionSecurity.getNextNonce() != null) {
					sipServletRequest.updateAuthorizationHeaders(true);
				}
				else if (sipSessionSecurity != null) {
					sipServletRequest.updateAuthorizationHeaders(false);
				}
				if(treatAsInitialRequest) {
					sipServletRequest.setRoutingState(RoutingState.INITIAL);
				}

				return sipServletRequest;
			} else {
				String errorMessage = "Couldn't create the subsequent request " + method + " for this session " + key + ", isValid " + isValid() + ", session state " + state + " , sessionCreatingDialog = " + sessionCreatingDialog;
				if(sessionCreatingDialog != null) {
					errorMessage += " , dialog state " + sessionCreatingDialog.getState();
				}
				errorMessage += " , sessionCreatingTransactionRequest = " + sessionCreatingTransactionRequest;
				throw new IllegalStateException(errorMessage);
			}
		}
		//Application Routing :
		//removing the route headers and adding them back again except the one
		//corresponding to the app that is creating the subsequent request
		//avoid going through the same app that created the subsequent request

		Request request = (Request) sipServletRequest.getMessage();
		final ListIterator<RouteHeader> routeHeaders = request.getHeaders(RouteHeader.NAME);
		request.removeHeader(RouteHeader.NAME);
		while (routeHeaders.hasNext()) {
			RouteHeader routeHeader = routeHeaders.next();
			String routeServerId = ((javax.sip.address.SipURI)routeHeader .getAddress().getURI()).
					getParameter(MessageDispatcher.RR_PARAM_SERVER_NAME);
			String routeAppNameHashed = ((javax.sip.address.SipURI)routeHeader .getAddress().getURI()).
				getParameter(MessageDispatcher.RR_PARAM_APPLICATION_NAME);
			String routeAppName = null;
			if(routeAppNameHashed != null) {
				routeAppName = sipFactory.getSipApplicationDispatcher().getApplicationNameFromHash(routeAppNameHashed);
			}
			if(routeAppName == null || !sipFactory.getSipApplicationDispatcher().getApplicationServerId().equals(routeServerId) ||
					!routeAppName.equals(getKey().getApplicationName())) {
				request.addHeader(routeHeader);
			}
		}

		if(sipSessionSecurity != null && sipSessionSecurity.getNextNonce() != null) {
			sipServletRequest.updateAuthorizationHeaders(true);
		}
		else if (sipSessionSecurity != null) {
			sipServletRequest.updateAuthorizationHeaders(false);
		}

		return sipServletRequest;
	}
1047684
private static void setAction(Method method, Object handlerBean) {
        Class<?>[] paramTypes = method.getParameterTypes();
        Class<?> returnType = method.getReturnType();
        Condition condition = Condition.newInstance(paramTypes[0], returnType);

        Handler existHandler = ACTION_MAP.get(condition);
        if (Objects.nonNull(existHandler)) {
            String message = "\n{method：" + method.getDeclaringClass().getName() + "." + method.getName()
                    + "}\n{method：" + existHandler.getMethod().getDeclaringClass().getName() + "."
                    + existHandler.getMethod().getName() + "} convert source and target is the same ";
            throw NonUniqueConverterException.of(message);
        }

        log.info("Mapped \"{sourceClass = {},targetClass = {}}\" onto {}", condition.getSourceClass(), returnType,
                method);
        Handler handler = Handler.newInstance(handlerBean, method);
        ACTION_MAP.put(condition, handler);
    }
532806
public HttpConnection setMethod(Method method) {
		// method
		try {
			this.conn.setRequestMethod(method.toString());
		} catch (ProtocolException e) {
			throw new HttpException(e);
		}

		// do input and output
		this.conn.setDoInput(true);
		if (Method.POST.equals(method) //
				|| Method.PUT.equals(method)//
				|| Method.PATCH.equals(method)//
				|| Method.DELETE.equals(method)) {
			this.conn.setDoOutput(true);
			this.conn.setUseCaches(false);
		}
		return this;
	}
1156245
public SoapClient setMethod(String methodName) {
		return setMethod(methodName, ObjectUtil.defaultIfNull(this.namespaceURI, XMLConstants.NULL_NS_URI));
	}
474482
protected boolean isHttpMethodMatch(String method) {
		if(StrUtil.isNotBlank(httpMethod) && httpMethod.equalsIgnoreCase(method) == false) {
			if(HuluSetting.isDevMode) {
				StaticLog.warn("Request [{}] method [{}] is not match [{}]", requestPath, method, httpMethod);
			}
			return false;
		}
		return true;
	}
961673
public HttpClientBuilder sslEnabledProtocols(String[] protocols) {
        if (protocols == null) {
            sslEnabledProtocols = null;
        } else {
            sslEnabledProtocols = new String[protocols.length];
            System.arraycopy(protocols, 0, sslEnabledProtocols, 0, protocols.length);
        }
        return this;
    }
574128
private List<Map<Class<? extends Annotation>, ParameterInfo<?>>> createParametersInfos(Method method) {
    if (method.getParameterTypes().length <= 2) {
      return Collections.emptyList();
    }

    List<Map<Class<? extends Annotation>, ParameterInfo<?>>> result = new ArrayList<>();
    Type[] parameterTypes = method.getGenericParameterTypes();
    Annotation[][] parameterAnnotations = method.getParameterAnnotations();

    for (int i = 2; i < parameterAnnotations.length; i++) {
      Annotation[] annotations = parameterAnnotations[i];
      Map<Class<? extends Annotation>, ParameterInfo<?>> paramAnnotations = new IdentityHashMap<>();

      for (Annotation annotation : annotations) {
        Class<? extends Annotation> annotationType = annotation.annotationType();
        ParameterInfo<?> parameterInfo;

        if (PathParam.class.isAssignableFrom(annotationType)) {
          parameterInfo = ParameterInfo.create(annotation,
                                               ParamConvertUtils.createPathParamConverter(parameterTypes[i]));
        } else if (QueryParam.class.isAssignableFrom(annotationType)) {
          parameterInfo = ParameterInfo.create(annotation,
                                               ParamConvertUtils.createQueryParamConverter(parameterTypes[i]));
        } else if (HeaderParam.class.isAssignableFrom(annotationType)) {
          parameterInfo = ParameterInfo.create(annotation,
                                               ParamConvertUtils.createHeaderParamConverter(parameterTypes[i]));
        } else {
          parameterInfo = ParameterInfo.create(annotation, null);
        }

        paramAnnotations.put(annotationType, parameterInfo);
      }

      // Must have either @PathParam, @QueryParam or @HeaderParam, but not two or more.
      int presence = 0;
      for (Class<? extends Annotation> annotationClass : paramAnnotations.keySet()) {
        if (SUPPORTED_PARAM_ANNOTATIONS.contains(annotationClass)) {
          presence++;
        }
      }
      if (presence != 1) {
        throw new IllegalArgumentException(
          String.format("Must have exactly one annotation from %s for parameter %d in method %s",
                        SUPPORTED_PARAM_ANNOTATIONS, i, method));
      }

      result.add(Collections.unmodifiableMap(paramAnnotations));
    }

    return Collections.unmodifiableList(result);
  }
458688
public function request($method = null)
	{
		# Verifying if was set method.
		if (!is_null($method)) $this->setMethod($method);
		
		# Verifying if URI is setted.
		if (is_null($this->uri)) {
			throw new RuntimeException('URI must be set before calling request method.');
		}
		
		# Setting default CURL options
		$this->setCurlOpts($this->defaultCurlOpts);
		
		# Verifying and preparing request for specified method.
		switch ($this->method) {
			case 'GET' : 
				// Specific routines for GET request.
				break;
			case 'POST' :
				$this->setCurlOpts(CURLOPT_POST, true); 
				
				if ($this->useRawData) {
					$this->setCurlOpts(CURLOPT_POSTFIELDS, $this->dataRaw);
				} else {
					// Verifying if has files to send
					if (count($this->files) > 0) {
						foreach ($this->files as $k => $v) {
							// Verifying if PHP version is over 5.4
							if (PHP_VERSION_ID < 50500) {
								$this->setParameterPost($k, "@$v");
							} else {
								$cFile = new CURLFile($v,mime_content_type($v),$k);
								$this->setParameterPost($k, $cFile);
							}
						} 
					}
					$this->setCurlOpts(CURLOPT_POSTFIELDS, $this->paramsPost);
				}
				break;
			case 'PUT' : 
				$this->setCurlOpts(CURLOPT_CUSTOMREQUEST, "PUT");
				if ($this->useRawData) {
					$this->setCurlOpts(CURLOPT_POSTFIELDS, $this->dataRaw);
				} else {
					$data = http_build_query($this->paramsPost);
					$this->setCurlOpts(CURLOPT_POSTFIELDS, $data);
				}
				break;
			case 'DELETE' : 
				$this->setCurlOpts(CURLOPT_CUSTOMREQUEST, "DELETE");
				break;
		}
		
		# Rendering GET parameters into a query string.
		$queryString = (count($this->paramsGet) > 0) ? '?' . http_build_query($this->paramsGet) : '';
		
		# Preparing and setting URI in CURL options
		$uri = $this->uri . $queryString;
		$this->setCurlOpts(CURLOPT_URL, $uri);
		
		# Parsing headers
		$headers = array();
		foreach ($this->headers as $key => $value) {
			$headers[] = $key . ': ' . $value;
		}
		$this->setCurlOpts(CURLOPT_HTTPHEADER, $headers);
		
		# Setting remaining options in CURL
		$this->setCurlOpts(array(
			CURLOPT_HTTP_VERSION=>$this->httpVersion,
		));
		
		# Initializing Request
		$ch = curl_init();
		curl_setopt_array($ch, $this->curlOpts);
		
		# Performing Request
		$response = curl_exec($ch);
		
		# Verifying if request was successfully executed.
		if (!$response) {
			throw new RuntimeException('cURL Request Error: ' . curl_errno($ch));
		}
		
		# Closing handle
		curl_close($ch);
		
		# Verifying if a custom response handler was set
		if (!is_null($this->responseHandler)) {
			$this->response = $this->responseHandler->fromString($response);
		} else {
			$this->response = Response::fromString($response);
		}
		
		# Saving last instance in Client
		$this->lastRequest = clone $this;
		
		# Verifying noReset control var
		if (!$this->noReset) {
			$this->reset();
		}
		
		return $this->response;
	}
446334
public void setAuthMethod(String method)
    {
        if (isStarted() && _authMethod!=null && !_authMethod.equals(method))
            throw new IllegalStateException("Handler started");
        _authMethod = method;
    }
296044
public static String httpRequest(String stringUrl, String method, Map<String, String> parameters,
      String input, String charset) throws IOException {
    URL url = new URL(stringUrl);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setDoOutput(true);
    conn.setRequestMethod(method);

    if (parameters != null) {
      for (Entry<String, String> entry : parameters.entrySet()) {
        conn.addRequestProperty(entry.getKey(), entry.getValue());
      }
    }

    if (input != null) {
      OutputStream output = null;
      try {
        output = conn.getOutputStream();
        output.write(input.getBytes(charset));
      } finally {
        if (output != null) {
          output.close();
        }
      }
    }

    return MyStreamUtils.readContent(conn.getInputStream());
  }
652128
private byte[] getBody(String method) {
        byte[] body = null;
    	String methodsWithInputEntity = HttpMethod.POST.name() + "|" + HttpMethod.PUT.name() + "|" + HttpMethod.DELETE.name();
    	if (method.matches(methodsWithInputEntity)) {
            if (isCompound()) {
                body = Utils.toBytes(getQueryInputEntity());
            }
            else {
                if (metadataJson.containsKey(INPUT_ENTITY)) {
                    JSONable data = (JSONable)commandParams.get(metadataJson.getString(INPUT_ENTITY));
                    if (data != null) {
                        body = Utils.toBytes(data.toJSON());
                    }
                }
            }
        }
        return body;
    }
1337586
public static Request create(String method,
                               String url,
                               Map<String, Collection<String>> headers,
                               byte[] body,
                               Charset charset) {
    checkNotNull(method, "httpMethod of %s", method);
    HttpMethod httpMethod = HttpMethod.valueOf(method.toUpperCase());
    return create(httpMethod, url, headers, body, charset);
  }
547353
public SoapClient setMethod(String methodName, String namespaceURI) {
		final List<String> methodNameList = StrUtil.split(methodName, ':');
		final QName qName;
		if (2 == methodNameList.size()) {
			qName = new QName(namespaceURI, methodNameList.get(1), methodNameList.get(0));
		} else {
			qName = new QName(namespaceURI, methodName);
		}
		return setMethod(qName);
	}
956807
public static Set<String> buildPath(Method method) {
		Class<?> controller = method.getDeclaringClass();

		Set<String> paths = new HashSet<String>();
		Set<String> controllerMapping = new HashSet<String>();
		Set<String> methodMapping = new HashSet<String>();

		if (isAnnotated(controller, RequestMapping.class)) {
			RequestMapping requestMapping = getAnnotation(controller, RequestMapping.class);
			if (valueMapping(requestMapping).length > 0 || pathMapping(requestMapping).length > 0) {
				controllerMapping = new HashSet<String>(Arrays.asList(ObjectArrays.concat(requestMapping.value(), pathMapping(requestMapping), String.class)));
			}
		}

		if (isAnnotated(method, RequestMapping.class)) {
			RequestMapping requestMapping = getAnnotation(method, RequestMapping.class);
			if (requestMapping.value().length > 0 || pathMapping(requestMapping).length > 0) {
				methodMapping = new HashSet<String>(Arrays.asList(ObjectArrays.concat(requestMapping.value(), pathMapping(requestMapping), String.class)));
			}
		}

		// if no path has been specified then adds an empty path to enter the following loop
		if (controllerMapping.isEmpty()) {
			controllerMapping.add("");
		}
		if(methodMapping.isEmpty()) {
			methodMapping.add("");
		}

		for (String controllerPath : controllerMapping) {
			for (String methodPath : methodMapping) {
				String resolvedPath;
				if(needsToJoinWithSlash(controllerPath, methodPath)) {
					resolvedPath = controllerPath + "/" + methodPath;
				} else {
					resolvedPath = controllerPath + methodPath;
				}
				paths.add(resolvedPath);
			}
		}
		
		for (String path : paths) {
			if(path.equals("")) {
				paths.remove(path);
				paths.add("/");
			}
		}

		return paths;
	}
484370
public void addAllowedMethod(String method) {

		Constraint.ensureNotEmpty(method, String.format("Invalid method '%s'", method));
		Constraint.ensureTrue(HttpMethod.isValidMethod(method), String.format("Invalid method '%s'", method));
		allowedMethods.add(method.toUpperCase());
	}