undertow

java: unit test lambda expression inside dispatcher

亡梦爱人 提交于 2019-12-11 16:31:15
问题 I have a class: public class RequestHandler implements HttpHandler { public void handleRequest(HttpServerExchange serverContext) throws Exception { serverContext.dispatch(() -> serverContext.getRequestReceiver() .receiveFullBytes((httpServerExchange, reqBytes) -> { // business logic along with few function call } ) ); } } I want to write a unit test case to test my business logic. I am not sure how to do it with 2 levels of a lambda expression insider a dispatcher? Can someone please suggest

Jboss7 : Undertow Spring Boot throwing 404

拈花ヽ惹草 提交于 2019-12-11 16:04:15
问题 I'm developing a Spring boot application. I'm building a war file for JBoss My war is building correctly , I'm using *-war.original as deployment for JBoss the deployment seems fine But when I make call to controller, it's throwing a 404 With embedded sever it's working fine pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven

Undertow: How to control choosing host depends on request body content?

元气小坏坏 提交于 2019-12-11 15:49:27
问题 I try to implement my own proxy like this: LoadBalancingProxyClient loadBalancer = new LoadBalancingProxyClient() .addHost(new URI("http://localhost:8080")) .addHost(new URI("http://localhost:7777")) .setConnectionsPerThread(20); Undertow reverseProxy = Undertow.builder() .addHttpListener(8081, "localhost") .setIoThreads(1) .setHandler(ProxyHandler.builder().setProxyClient(loadBalancer).setMaxRequestTime(30000).build()) .build(); reverseProxy.start(); I want to have control over choosing

How can I configure Undertow to add a charset to text/ content types?

走远了吗. 提交于 2019-12-11 13:57:28
问题 I have a programmatically started Undertow server (not running as part of any container). My static resources, served with a ResourceHander on a PathResourceManager are UTF-8 encoded, but the mime type sent by the PathResourceManager does not include a charset. I'd rather not stoop to building a whole new MimeMappings table and installing it. Is there any way to use a handler to add the charset to responses with a CONTENT-TYPE starting with `text/'? 回答1: I did this in my code: handler = path(

Redirect http to https on spring boot embedded undertow

淺唱寂寞╮ 提交于 2019-12-11 03:47:47
问题 I am using spring boot (1.2.3) and embedded undertow. For security reasons I would prefer to redirect any http request to https but I cannot find an example for doing this. Here is an example for spring boot and tomcat: Spring boot - Embeded Tomcat HTTP to HTTPS redirect Does anyone have a solution for doing this with undertow? 回答1: you could add Spring-Security to your project and then configure Spring-Security to enforce https. You could find a small example in the JavaDoc of org

Serving static content in UndertowJaxrsServer

*爱你&永不变心* 提交于 2019-12-10 11:58:41
问题 I'm trying to serve static content through a ResourceHandler in my Undertow server that has a RestEasy deployment. public class Server { public static void main(String[] args) throws Exception { UndertowJaxrsServer server = new UndertowJaxrsServer(); Undertow.Builder serverBuilder = Undertow .builder() .addHttpListener(8080, "0.0.0.0") .setHandler( Handlers.path().addPrefixPath( "/web", new ResourceHandler(new PathResourceManager(Paths.get("/some/fixed/path"),100)) .setDirectoryListingEnabled

Undertow how to do Non-blocking IO?

丶灬走出姿态 提交于 2019-12-10 02:17:28
问题 I am using Undertow to create a simple application. public class App { public static void main(String[] args) { Undertow server = Undertow.builder().addListener(8080, "localhost") .setHandler(new HttpHandler() { public void handleRequest(HttpServerExchange exchange) throws Exception { Thread.sleep(5000); exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain"); exchange.getResponseSender().send("Hello World"); } }).build(); server.start(); } } I open a browser tab on localhost

Image/Media MIME type responses in Undertow

痞子三分冷 提交于 2019-12-08 02:51:49
问题 I've been struggling trying to find a way to deliver .jpeg, .png or other contents in Undertow. Sending byte[] won't work and since Undertow is Non-blocking, I don't want to write the file on the output by doing the usual: exchange.getOutputStream().write(myFileByteArray); Is there any other way I can achieve it? I also encoded the image in Base64 using Undertow's default Base64 library, but didn't work either. Edit: providing some code: This is my method that encodes a file. It works for .js

How do I configure Undertow handlers to support proper rewriting for SPA bookmarking?

依然范特西╮ 提交于 2019-12-08 02:01:48
问题 I am trying to configure JBoss EAP 7 (via Undertow) to properly rewrite any SPA URLS back to the SPA's index.html using Undertow handlers. Unfortunately, my API is located at /api , so I need to let any requests pass through which start with /api . Here is my current configuration (lifted from another SO answer): not equals(%R, '/my-app') and not equals(%R, '/my-app/') and not equals(%R, '/my-app/index.html') and not path-prefix('/my-app/api') and not regex('/my-app/.*\.js') and regex('/my

Clojure Immutant 2 server Undertow; how to handle http POST?

柔情痞子 提交于 2019-12-07 23:13:58
问题 Putting the following line into my compojure defroutes to use clojure-paypal-ipn calling the two handler functions. (POST "/paypal/ipn" [] (make-ipn-handler payment/paypal-data payment/paypal-error)) How do I handle a POST request within Immutant? I'm using Immutant 2.0 with Clojure 1.7-beta1 and building off the Immutant feature demo. Posting directly with cURL give these same results, although I'm trying to use PayPal IPN. 17:29:40.220 ERROR [io.undertow.request] (XNIO-1 task-1) Undertow