Examples of RHTTPResponse


Examples of org.eclipse.jetty.rhttp.client.RHTTPResponse

            {
                int statusCode = exchange.getResponseStatus();
                String statusMessage = exchange.getResponseMessage();
                Map<String, String> responseHeaders = exchange.getResponseHeaders();
                byte[] responseBody = exchange.getResponseBody();
                RHTTPResponse response = new RHTTPResponse(request.getId(), statusCode, statusMessage, responseHeaders, responseBody);
                client.deliver(response);
            }
            else
            {
                int statusCode = HttpServletResponse.SC_SERVICE_UNAVAILABLE;
                String statusMessage = "Gateway error";
                HashMap<String, String> responseHeaders = new HashMap<String, String>();
                responseHeaders.put("Connection", "close");
                byte[] responseBody = new byte[0];
                RHTTPResponse response = new RHTTPResponse(request.getId(), statusCode, statusMessage, responseHeaders, responseBody);
                client.deliver(response);
            }
        }
View Full Code Here

Examples of org.eclipse.jetty.rhttp.client.RHTTPResponse

                            // Save the request id
                            requestId.set(request.getId());

                            // Wait until external timeout expires
                            Thread.sleep(externalTimeout + 1000L);
                            RHTTPResponse response = new RHTTPResponse(request.getId(), 200, "OK", new HashMap<String, String>(), request.getBody());
                            client.deliver(response);
                        }
                        catch (Exception x)
                        {
                            exceptionRef.set(x);
View Full Code Here

Examples of org.eclipse.jetty.rhttp.client.RHTTPResponse

                {
                    public void onRequest(RHTTPRequest request)
                    {
                        try
                        {
                            RHTTPResponse response = new RHTTPResponse(request.getId(), 200, "OK", new HashMap<String, String>(), request.getBody());
                            client.deliver(response);
                        }
                        catch (Exception x)
                        {
                            exception.set(x);
View Full Code Here

Examples of org.eclipse.jetty.rhttp.client.RHTTPResponse

            return;
        }

        byte[] body = Utils.read(httpRequest.getInputStream());

        RHTTPResponse response = RHTTPResponse.fromFrameBytes(body);

        ExternalRequest externalRequest = gateway.removeExternalRequest(response.getId());
        if (externalRequest != null)
        {
            externalRequest.respond(response);
            logger.debug("Deliver request from device {}, gateway request {}, response {}", new Object[] {targetId, externalRequest, response});
        }
View Full Code Here

Examples of org.eclipse.jetty.rhttp.client.RHTTPResponse

                    {
                        try
                        {
                            // Wait until gateway timeout expires
                            Thread.sleep(gatewayTimeout + 1000L);
                            RHTTPResponse response = new RHTTPResponse(request.getId(), 200, "OK", new HashMap<String, String>(), request.getBody());
                            client.deliver(response);
                        }
                        catch (Exception x)
                        {
                            exceptionRef.set(x);
View Full Code Here

Examples of org.eclipse.jetty.rhttp.client.RHTTPResponse

            this.client = client;
        }

        public void onRequest(RHTTPRequest request) throws Exception
        {
            RHTTPResponse response = new RHTTPResponse(request.getId(), 200, "OK", new HashMap<String, String>(), request.getBody());
            client.deliver(response);
        }
View Full Code Here

Examples of org.eclipse.jetty.rhttp.client.RHTTPResponse

        Map<String, String> headers = new LinkedHashMap<String, String>();
        headers.put("X", "X");
        headers.put("Y", "Y");
        headers.put("Z", "Z");
        byte[] body = "BODY".getBytes("UTF-8");
        RHTTPResponse response1 = new RHTTPResponse(id, statusCode, statusMessage, headers, body);
        byte[] responseBytes1 = response1.getResponseBytes();
        RHTTPResponse response2 = RHTTPResponse.fromResponseBytes(id, responseBytes1);
        assertEquals(id, response2.getId());
        assertEquals(statusCode, response2.getStatusCode());
        assertEquals(statusMessage, response2.getStatusMessage());
        assertEquals(headers, response2.getHeaders());
        assertTrue(Arrays.equals(response2.getBody(), body));

        byte[] responseBytes2 = response2.getResponseBytes();
        assertTrue(Arrays.equals(responseBytes1, responseBytes2));
    }
View Full Code Here

Examples of org.eclipse.jetty.rhttp.client.RHTTPResponse

        Map<String, String> headers = new LinkedHashMap<String, String>();
        headers.put("X", "X");
        headers.put("Y", "Y");
        headers.put("Z", "Z");
        byte[] body = "BODY".getBytes("UTF-8");
        RHTTPResponse response1 = new RHTTPResponse(id, statusCode, statusMessage, headers, body);
        byte[] frameBytes1 = response1.getFrameBytes();
        RHTTPResponse response2 = RHTTPResponse.fromFrameBytes(frameBytes1);
        assertEquals(id, response2.getId());
        assertEquals(statusCode, response2.getStatusCode());
        assertEquals(response2.getStatusMessage(), statusMessage);
        assertEquals(headers, response2.getHeaders());
        assertTrue(Arrays.equals(response2.getBody(), body));

        byte[] frameBytes2 = response2.getFrameBytes();
        assertTrue(Arrays.equals(frameBytes1, frameBytes2));
    }
View Full Code Here

Examples of org.eclipse.jetty.rhttp.client.RHTTPResponse

                });
                client.connect();

                assertTrue(serverLatch.await(1000, TimeUnit.MILLISECONDS));

                client.deliver(new RHTTPResponse(1, 200, "OK", new LinkedHashMap<String, String>(), new byte[0]));

                assertTrue(deliverLatch.await(1000, TimeUnit.MILLISECONDS));
            }
            finally
            {
View Full Code Here

Examples of org.eclipse.jetty.rhttp.client.RHTTPResponse

                // reads up to the connection buffer's capacities
                while (endPoint.getIn().length() > 0)
                    connection.handle();

                byte[] responseBytes = endPoint.getOut().asArray();
                RHTTPResponse response = RHTTPResponse.fromResponseBytes(request.getId(), responseBytes);
                client.deliver(response);
            }
            catch (Exception x)
            {
                LOG.debug(x);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.