Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

26
LINES

< > BotCompany Repo | #1033324 // HandleProxyRequest

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (14441L/87K).

1  
sclass HandleProxyRequest {
2  
  HostAndPort hap;
3  
  bool rewriteHost; // unused?
4  
  bool rewritePort;
5  
  NanoHTTPD.IHTTPSession session;
6  
  IVF1<StandaloneHttpProxy.Request> customizeRequest;
7  
  
8  
  new StandaloneHttpProxy proxy;
9  
  
10  
  run ctex {
11  
    S headers = windowsLineBreaks(lines(concatLists(
12  
      ll(session.getMethod() + " " + session.getFullURI() + " " + session.getProtocolVersion()),
13  
      withoutStartingWithIC("Host:", session.getHeaderLines())
14  
    )));
15  
    
16  
    S domain = dropPortFromHost(mapGet(session.getHeaders(), "host"));
17  
    
18  
    proxy.rewriteHostHeader = rewritePort;
19  
    proxy.forwardServerAndPort = req -> hap;
20  
    proxy.takeOverIncomingSocket(domain, session.getSocket(),
21  
      session.getInputStream(),
22  
      session.getOutputStream(),
23  
      toUtf8(printQuoted("HEADERS: ", headers)),
24  
      customizeRequest);
25  
  }
26  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033324
Snippet name: HandleProxyRequest
Eternal ID of this version: #1033324/5
Text MD5: 8fa6b546515d66e4f4dc2173e11f6401
Transpilation MD5: 5997e857a0b54052cf39156ef0544432
Author: stefan
Category: javax / gazelle v
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-04-17 20:20:36
Source code size: 860 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 193 / 311
Version history: 4 change(s)
Referenced in: [show references]