/** * Returns the {@link HttpMethod} represented by the specified name. * If the specified name is a standard HTTP method name, a cached instance * will be returned. Otherwise, a new instance will be returned. */ public static HttpMethod valueOf(String name) { HttpMethod result = methodMap.get(name); return result != null ? result : new HttpMethod(name); }
/** * Returns the {@link HttpMethod} represented by the specified name. * If the specified name is a standard RTSP getMethod name, a cached instance * will be returned. Otherwise, a new instance will be returned. */ public static HttpMethod valueOf(String name) { if (name == null) { throw new NullPointerException("name"); } name = name.trim().toUpperCase(); if (name.isEmpty()) { throw new IllegalArgumentException("empty name"); } HttpMethod result = methodMap.get(name); if (result != null) { return result; } else { return new HttpMethod(name); } }
@Path("/favicon.ico") @GET public void favicon(RakamHttpRequest request) { sendFile(request, new File(directory.getPath(), "favicon.ico")); }
@Path("/check-sentry") @GET public void checkSentry(RakamHttpRequest request) { request.response(JsonHelper.encode(checkSentry()), OK).end(); }
@Path("/check-configuration") @GET public void checkConfiguration(RakamHttpRequest request) { request.response(JsonHelper.encode(ImmutableMap.of( "sentry", checkSentry(), "scheduledEmailEnabled", config.getScreenCaptureService() != null, "disableTracking", config.getDisableTracking())), OK).end(); }
Map<String, Object> headers = httpSend.getHeaders(); httpMethod = new io.netty.handler.codec.http.HttpMethod(method.name());
@Override public HttpMethod method() { return new HttpMethod(method); }
/** * Returns the {@link HttpMethod} represented by the specified name. * If the specified name is a standard HTTP method name, a cached instance * will be returned. Otherwise, a new instance will be returned. */ public static HttpMethod valueOf(String name) { HttpMethod result = methodMap.get(name); return result != null ? result : new HttpMethod(name); }
/** * Returns the {@link HttpMethod} represented by the specified name. * If the specified name is a standard HTTP method name, a cached instance * will be returned. Otherwise, a new instance will be returned. */ public static HttpMethod valueOf(String name) { HttpMethod result = methodMap.get(name); return result != null ? result : new HttpMethod(name); }
/** * Returns the {@link HttpMethod} represented by the specified name. * If the specified name is a standard HTTP method name, a cached instance * will be returned. Otherwise, a new instance will be returned. */ public static HttpMethod valueOf(String name) { HttpMethod result = methodMap.get(name); return result != null ? result : new HttpMethod(name); }
private static HttpMethod getHttpMethod(HttpCarbonMessage outboundRequestMsg) { HttpMethod httpMethod; if (null != outboundRequestMsg.getProperty(Constants.HTTP_METHOD)) { httpMethod = new HttpMethod((String) outboundRequestMsg.getProperty(Constants.HTTP_METHOD)); } else { httpMethod = new HttpMethod(Constants.HTTP_POST_METHOD); } return httpMethod; }
/** * Returns the {@link HttpMethod} represented by the specified name. * If the specified name is a standard HTTP method name, a cached instance * will be returned. Otherwise, a new instance will be returned. */ public static HttpMethod valueOf(String name) { HttpMethod result = methodMap.get(name); return result != null ? result : new HttpMethod(name); }
/** * Returns the {@link HttpMethod} represented by the specified name. * If the specified name is a standard RTSP getMethod name, a cached instance * will be returned. Otherwise, a new instance will be returned. */ public static HttpMethod valueOf(String name) { if (name == null) { throw new NullPointerException("name"); } name = name.trim().toUpperCase(); if (name.isEmpty()) { throw new IllegalArgumentException("empty name"); } HttpMethod result = methodMap.get(name); if (result != null) { return result; } else { return new HttpMethod(name); } }
/** * Returns the {@link HttpMethod} represented by the specified name. * If the specified name is a standard RTSP getMethod name, a cached instance * will be returned. Otherwise, a new instance will be returned. */ public static HttpMethod valueOf(String name) { if (name == null) { throw new NullPointerException("name"); } name = name.trim().toUpperCase(); if (name.isEmpty()) { throw new IllegalArgumentException("empty name"); } HttpMethod result = methodMap.get(name); if (result != null) { return result; } else { return new HttpMethod(name); } }
/** * Returns the {@link HttpMethod} represented by the specified name. * If the specified name is a standard RTSP getMethod name, a cached instance * will be returned. Otherwise, a new instance will be returned. */ public static HttpMethod valueOf(String name) { if (name == null) { throw new NullPointerException("name"); } name = name.trim().toUpperCase(); if (name.isEmpty()) { throw new IllegalArgumentException("empty name"); } HttpMethod result = methodMap.get(name); if (result != null) { return result; } else { return new HttpMethod(name); } }
/** * Returns the {@link HttpMethod} represented by the specified name. * If the specified name is a standard RTSP getMethod name, a cached instance * will be returned. Otherwise, a new instance will be returned. */ public static HttpMethod valueOf(String name) { if (name == null) { throw new NullPointerException("name"); } name = name.trim().toUpperCase(); if (name.isEmpty()) { throw new IllegalArgumentException("empty name"); } HttpMethod result = methodMap.get(name); if (result != null) { return result; } else { return new HttpMethod(name); } }
using (var client = new HttpClient()) { var httpRequest = new HttpRequestMessage(new HttpMethod("POST"), _uri); //client.BaseAddress = new Uri(_uri); try { client.Timeout = TimeSpan.FromSeconds(30); var _cancelTokenSource = new CancellationTokenSource(); var _cancelToken = _cancelTokenSource.Token; var response = await client.SendAsync(httpRequest, _cancelToken).ConfigureAwait(false); resp = await response.Content.ReadAsStringAsync().ConfigureAwait(false); } catch (Exception e) { Debug.WriteLine("HTTP ERROR: " + e.Message); throw e; } }
/** * Create redirect request. * * @return HTTPCarbonMessage with request properties * @throws MalformedURLException */ private HTTPCarbonMessage createHttpCarbonRequest() throws MalformedURLException { if (LOG.isDebugEnabled()) { LOG.debug("Create redirect request with http method : " + redirectState.get(Constants.HTTP_METHOD)); } URL locationUrl = new URL(redirectState.get(Constants.LOCATION)); HttpMethod httpMethod = new HttpMethod(redirectState.get(Constants.HTTP_METHOD)); HTTPCarbonMessage httpCarbonRequest = new HTTPCarbonMessage( new DefaultHttpRequest(HttpVersion.HTTP_1_1, httpMethod, "")); httpCarbonRequest.setProperty(Constants.PORT, locationUrl.getPort() != -1 ? locationUrl.getPort() : getDefaultPort(locationUrl.getProtocol())); httpCarbonRequest.setProperty(Constants.PROTOCOL, locationUrl.getProtocol()); httpCarbonRequest.setProperty(Constants.HOST, locationUrl.getHost()); httpCarbonRequest.setProperty(Constants.HTTP_METHOD, redirectState.get(Constants.HTTP_METHOD)); httpCarbonRequest.setProperty(Constants.REQUEST_URL, locationUrl.getPath()); httpCarbonRequest.setProperty(Constants.TO, locationUrl.getPath()); StringBuffer host = new StringBuffer(locationUrl.getHost()); if (locationUrl.getPort() != -1 && locationUrl.getPort() != Constants.DEFAULT_HTTP_PORT && locationUrl.getPort() != Constants.DEFAULT_HTTPS_PORT) { host.append(Constants.COLON).append(locationUrl.getPort()); } httpCarbonRequest.setHeader(Constants.HOST, host.toString()); httpCarbonRequest.setEndOfMsgAdded(true); return httpCarbonRequest; }
@Override public Publisher<Void> apply(HttpChannel<IN, OUT> inoutHttpChannel) { try { final NettyHttpChannel<IN, OUT> ch = ((NettyHttpChannel<IN, OUT>) inoutHttpChannel); ch.getNettyRequest() .setUri(currentURI.getPath() + (currentURI.getQuery() == null ? "" : "?" + currentURI.getQuery())) .setMethod(new HttpMethod(method.getName())) .headers() .add(HttpHeaders.Names.HOST, currentURI.getHost()) .add(HttpHeaders.Names.ACCEPT, "*/*"); if (handler != null) { Publisher<Void> p = handler.apply(ch); reply.onNext(ch); return p; } else { reply.onNext(ch); return Streams.empty(); } } catch (Throwable t) { reply.onError(t); return Promises.error(t); } }
@SuppressWarnings("unchecked") public static HttpRequest createHttpRequest(HTTPCarbonMessage msg) { HttpMethod httpMethod; if (null != msg.getProperty(Constants.HTTP_METHOD)) { httpMethod = new HttpMethod((String) msg.getProperty(Constants.HTTP_METHOD)); } else { httpMethod = new HttpMethod(DEFAULT_HTTP_METHOD_POST); } HttpVersion httpVersion; if (null != msg.getProperty(Constants.HTTP_VERSION)) { httpVersion = new HttpVersion((String) msg.getProperty(Constants.HTTP_VERSION), true); } else { httpVersion = new HttpVersion(DEFAULT_VERSION_HTTP_1_1, true); } if ((String) msg.getProperty(Constants.TO) == null) { msg.setProperty(Constants.TO, "/"); } HttpRequest outgoingRequest = new DefaultHttpRequest(httpVersion, httpMethod, (String) msg.getProperty(Constants.TO), false); HttpHeaders headers = msg.getHeaders(); outgoingRequest.headers().setAll(headers); return outgoingRequest; }