Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NumberFormatException using IPv6 addresses #30

Closed
asoldano opened this issue Mar 15, 2012 · 2 comments
Closed

java.lang.NumberFormatException using IPv6 addresses #30

asoldano opened this issue Mar 15, 2012 · 2 comments

Comments

@asoldano
Copy link

Hi,
I'm using version 0.4. The HttpRequestHandler chokes on IPv6 addresses:

2012-03-15 18:49:52,095 INFO [org.littleshoot.proxy.HttpRequestHandler:607] Caught an exception on browser to proxy channel: [id: 0x27972e3a, /0:0:0:0:0:0:0:1:49725 => /0:0:0:0:0:0:0:1:19385]
java.lang.NumberFormatException: For input string: ":1]:8080"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at org.littleshoot.proxy.HttpRequestHandler.newChannelFuture(HttpRequestHandler.java:450)
at org.littleshoot.proxy.HttpRequestHandler.processMessage(HttpRequestHandler.java:321)
at org.littleshoot.proxy.HttpRequestHandler.messageReceived(HttpRequestHandler.java:213)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndfireMessageReceived(ReplayingDecoder.java:522)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:506)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:443)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:349)
at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:280)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:200)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Below is a patch for solving this:

diff --git a/src/main/java/org/littleshoot/proxy/HttpRequestHandler.java b/src/main/java/org/littleshoot/proxy/HttpRequestHandler.java
index 864b7f0..7563207 100644
--- a/src/main/java/org/littleshoot/proxy/HttpRequestHandler.java
+++ b/src/main/java/org/littleshoot/proxy/HttpRequestHandler.java
@@ -443,15 +443,30 @@ public class HttpRequestHandler extends SimpleChannelUpstreamHandler
final Channel browserToProxyChannel) {
final String host;
final int port;

  •    if (hostAndPort.contains(":")) {
    
  •        host = StringUtils.substringBefore(hostAndPort, ":");
    
  •        final String portString = 
    
  •            StringUtils.substringAfter(hostAndPort, ":");
    
  •        port = Integer.parseInt(portString);
    
  •    }
    
  •    else {
    
  •        host = hostAndPort;
    
  •        port = 80;
    
  •    if (hostAndPort.contains("[") && hostAndPort.contains("]")) {
    
  •       int idx = hostAndPort.lastIndexOf("]");
    
  •       int cIdx = hostAndPort.lastIndexOf(":");
    
  •       if (cIdx > idx) {
    
  •          host = hostAndPort.substring(0, idx + 1);
    
  •          final String portString = 
    
  •              hostAndPort.substring(cIdx + 1);
    
  •          port = Integer.parseInt(portString);
    
  •       }
    
  •       else {
    
  •          host = hostAndPort;
    
  •          port = 80;
    
  •       }
    
  •    } else {
    
  •       if (hostAndPort.contains(":")) {
    
  •           host = StringUtils.substringBefore(hostAndPort, ":");
    
  •           final String portString = 
    
  •               StringUtils.substringAfter(hostAndPort, ":");
    
  •           port = Integer.parseInt(portString);
    
  •       }
    
  •       else {
    
  •           host = hostAndPort;
    
  •           port = 80;
    
  •       }
     }
    
     // Configure the client.
    

Please evaluate.
Thanks

@jekh
Copy link
Collaborator

jekh commented May 25, 2015

I was a little surprised when I discovered that this issue still exists! I just submitted PR #211 which should fix it.

@adamfisk
Copy link
Owner

Fixed in #211

arushi315 pushed a commit to arushi315/LittleProxy that referenced this issue Oct 9, 2019
* Versioning test jgitflow (adamfisk#27)

* Added jgitflow plugin

* Added release section

* Versioning test jgitflow (adamfisk#28)

* Added jgitflow plugin

* Added custom version and remove ssh agent

* Added maven plugin and circle code that make release (adamfisk#29)

* Fix gitflow plugin dependency (adamfisk#30)

* test code

* test code

* test code

* deploy any branch

* Added plugin to dependency management

* comment code

* trigger build

* skip tests

* skip tests

* try to fix dependencies

* full name of plugin

* remove gitflow from report section

* removed gitfloe from dependency management

* added gitflow from dependency management

* added gitflow to release

* added gitflow configs to command

* remove dependency

* remove no needed commands

* possible fix

* fix gitflow release (adamfisk#31)

* test code

* test code

* test code

* deploy any branch

* comment code

* trigger build

* skip tests

* skip tests

* try to fix dependencies

* full name of plugin

* remove gitflow from report section

* removed gitfloe from dependency management

* added gitflow from dependency management

* added gitflow to release

* added gitflow configs to command

* remove dependency

* remove no needed commands

* possible fix

* Ignore some commands. Added configs in all gitflow declaration

* release any branch

* Test no needed configs

* Test no needed configs

* Test no needed configs

* revert changes for test

* Fix gitflow release (adamfisk#32)

* test code

* test code

* test code

* deploy any branch

* comment code

* trigger build

* skip tests

* skip tests

* try to fix dependencies

* full name of plugin

* remove gitflow from report section

* removed gitfloe from dependency management

* added gitflow from dependency management

* added gitflow to release

* added gitflow configs to command

* remove dependency

* remove no needed commands

* possible fix

* Ignore some commands. Added configs in all gitflow declaration

* release any branch

* Test no needed configs

* Test no needed configs

* Test no needed configs

* revert changes for test

* Another try to release

* pull branch

* revert formatting

* update versions for 1.1.5.0-vgs-test release

* Fix gitflow release (adamfisk#33)

* test code

* test code

* test code

* deploy any branch

* comment code

* trigger build

* skip tests

* skip tests

* try to fix dependencies

* full name of plugin

* remove gitflow from report section

* removed gitfloe from dependency management

* added gitflow from dependency management

* added gitflow configs to command

* remove dependency

* remove no needed commands

* possible fix

* Ignore some commands. Added configs in all gitflow declaration

* release any branch

* Test no needed configs

* Test no needed configs

* Test no needed configs

* revert changes for test

* Another try to release

* pull branch

* revert formatting

* change version. skip tests

* Fix gitflow release (adamfisk#34)

* test code

* test code

* test code

* deploy any branch

* comment code

* trigger build

* skip tests

* skip tests

* try to fix dependencies

* full name of plugin

* remove gitflow from report section

* removed gitfloe from dependency management

* added gitflow from dependency management

* added gitflow configs to command

* remove dependency

* remove no needed commands

* possible fix

* Ignore some commands. Added configs in all gitflow declaration

* release any branch

* Test no needed configs

* Test no needed configs

* Test no needed configs

* revert changes for test

* Another try to release

* pull branch

* revert formatting

* change version. skip tests

* reset uncommited

* fiz

* update versions for 1.1.5.0-vgs-test release

* update for next development version 1.1.6.0-vgs-test-SNAPSHOT

* test code

* test code

* test code

* deploy any branch

* comment code

* trigger build

* skip tests

* skip tests

* try to fix dependencies

* remove gitflow from report section

* removed gitfloe from dependency management

* added gitflow from dependency management

* added gitflow configs to command

* remove dependency

* remove no needed commands

* possible fix

* Ignore some commands. Added configs in all gitflow declaration

* release any branch

* Test no needed configs

* Test no needed configs

* Test no needed configs

* revert changes for test

* Another try to release

* pull branch

* revert formatting

* change version. skip tests

* fiz

* revert version

* change release branch

* change branch name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants