GithubHelp home page GithubHelp logo

Comments (12)

tomakehurst avatar tomakehurst commented on July 19, 2024

Hi,

I'm pretty pushed for time at the moment, so I can't guarantee I can fix this any time soon.

However, WireMock's code is pretty accessible. If you'd like to patch it yourself I'm happy to provide some pointers and accept a pull request.

In the meantime, please could you send some more detail i.e. your stub mappings and stack trace?

Thanks,
Tom

from wiremock.

senseysensor avatar senseysensor commented on July 19, 2024

Firstly, thanks for ultra quick reply!

Well, I use WireMock as standalone application as browser proxy.
I have following in my log:

2013-08-14 15:07:15 Received request to /pagestat/PageStatEntry?cookie=BBCD40B5E60A4809B65493C5368D0EBE&time=1376482034673&location=http%3A%2F%2Flocalhost%3A52139%2Ftest_1.html&referrer=&is_flash=1&session_id=775253134&version=3.0.91/1.48&sw=1920&sh=1080&scd=32&spd=32&param1=~cm_banners~&result=[{%22link%22:%22http%3A%2F%2Falpinists.com.ua%2Fiframe.html%22,%20%22pos%22:%22512%22},{%22link%22:%22http%3A%2F%2Fi.holder.com.ua%2Fh%2F3%2F2%2F302_1.swf%3Flink1%3Dlocal%22,%20%22pos%22:%22258%22}]
2013-08-14 15:07:15.052:WARN::/pagestat/PageStatEntry
java.lang.IllegalArgumentException
    at java.net.URI.create(URI.java:841)
    at com.github.tomakehurst.wiremock.jetty.ServletContainerUtils.isBrowserProxyRequest(ServletContainerUtils.java:30)
    at com.github.tomakehurst.wiremock.servlet.HttpServletRequestAdapter.isBrowserProxyRequest(HttpServletRequestAdapter.java:140)
    at com.github.tomakehurst.wiremock.verification.LoggedRequest.createFrom(LoggedRequest.java:44)
    at com.github.tomakehurst.wiremock.verification.InMemoryRequestJournal.requestReceived(InMemoryRequestJournal.java:55)
    at com.github.tomakehurst.wiremock.verification.InMemoryRequestJournal.requestReceived(InMemoryRequestJournal.java:60)
    at com.github.tomakehurst.wiremock.core.WireMockApp.serveStubFor(WireMockApp.java:75)
    at com.github.tomakehurst.wiremock.http.StubRequestHandler.handleRequest(StubRequestHandler.java:35)
    at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:38)
    at com.github.tomakehurst.wiremock.servlet.HandlerDispatchingServlet.service(HandlerDispatchingServlet.java:75)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at wiremock.org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at wiremock.org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
    at wiremock.org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
    at wiremock.org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
    at wiremock.org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at wiremock.org.mortbay.jetty.Server.handle(Server.java:326)
    at wiremock.org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at wiremock.org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
    at wiremock.org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
    at wiremock.org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at wiremock.org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at wiremock.org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
    at com.github.tomakehurst.wiremock.jetty.DelayableSocketConnector$1.run(DelayableSocketConnector.java:49)
    at wiremock.org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
2013-08-14 15:07:15 Received request to /pagestat/PageStatEntry?cookie=BBCD40B5E60A4809B65493C5368D0EBE&time=1376482034319&location=http%3A%2F%2Flocalhost%3A52139%2Ftest_1.html&referrer=&is_flash=1&session_id=775253134&version=3.0.91/1.48&sw=1920&sh=1080&scd=32&spd=32&param1=~cm_timer~&param2=0&param3=1080&param5=0
2013-08-14 15:07:15.059:WARN::/pagestat/PageStatEntry
java.lang.IllegalArgumentException
    at java.net.URI.create(URI.java:841)
    at com.github.tomakehurst.wiremock.jetty.ServletContainerUtils.isBrowserProxyRequest(ServletContainerUtils.java:30)
    at com.github.tomakehurst.wiremock.servlet.HttpServletRequestAdapter.isBrowserProxyRequest(HttpServletRequestAdapter.java:140)
    at com.github.tomakehurst.wiremock.verification.LoggedRequest.createFrom(LoggedRequest.java:44)
    at com.github.tomakehurst.wiremock.verification.InMemoryRequestJournal.requestReceived(InMemoryRequestJournal.java:55)
    at com.github.tomakehurst.wiremock.verification.InMemoryRequestJournal.requestReceived(InMemoryRequestJournal.java:60)
    at com.github.tomakehurst.wiremock.core.WireMockApp.serveStubFor(WireMockApp.java:75)
    at com.github.tomakehurst.wiremock.http.StubRequestHandler.handleRequest(StubRequestHandler.java:35)
    at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:38)
    at com.github.tomakehurst.wiremock.servlet.HandlerDispatchingServlet.service(HandlerDispatchingServlet.java:75)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at wiremock.org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at wiremock.org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
    at wiremock.org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
    at wiremock.org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
    at wiremock.org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at wiremock.org.mortbay.jetty.Server.handle(Server.java:326)
    at wiremock.org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at wiremock.org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
    at wiremock.org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
    at wiremock.org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at wiremock.org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at wiremock.org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
    at com.github.tomakehurst.wiremock.jetty.DelayableSocketConnector$1.run(DelayableSocketConnector.java:49)
    at wiremock.org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

And mappings are as follows:

{
  "mappings" : [ {
    "request" : {
      "urlPattern" : ".*/pagestat/PageStatEntry.*",
      "method" : "ANY"
    },
    "response" : {
      "status" : 200,
      "body" : "tnsOnStatResult({\"result\":\"success_STUB\"});"
    }
  } ]
}

Let's do it in next way:
I don't write on Java at all. But if there will be no other way, I will ask guys from another department (who write in Java) for help. And hope together we will overcome an issue.

from wiremock.

tomakehurst avatar tomakehurst commented on July 19, 2024

Have you considered that having unescaped meta-characters in your URL might be an application bug?

Admittedly Java's URI class seems to have a stricter interpretation of what constitutes a valid URL than the rest of the world.

from wiremock.

senseysensor avatar senseysensor commented on July 19, 2024

Well... Maybe you are right. I would not call this bug (altogether everything works normal), but I believe is something I can (and maybe should) change in our side.

from wiremock.

tomakehurst avatar tomakehurst commented on July 19, 2024

When I next get some time to update WireMock I'll have a look at the feasibility of swapping out the URI class for a more liberal implementation.

from wiremock.

ckurban avatar ckurban commented on July 19, 2024

Hi Tom , Any update on this issue as I have the same issue. OR would you suggest any work around ?

from wiremock.

tomakehurst avatar tomakehurst commented on July 19, 2024

No progress on this, but if you're able to escape the characters in the URL your client is sending that should work around the problem.

from wiremock.

wojciechbulaty avatar wojciechbulaty commented on July 19, 2024

I had an issue with this in an old legacy application when doing a record/replay. It was hard to change that application so I had to make a fix in Wiremock. I have got a fix for this but did not have the time to merge it back yet. I have put it on my todo list now and once prioritized will merge it to Wiremock master.

from wiremock.

tomakehurst avatar tomakehurst commented on July 19, 2024

I'd be keen to see how you've fixed that. The reason I haven't tackled it yet is that the URI class (which is the source of overly strict parsing) is used all over the place and fixing it properly would mean a wholesale replacement of it.

I'd actually like to write my own URL wrangling library so that I can solve this problem generically, but also to provide a richer API for query splitting etc.

from wiremock.

wojciechbulaty avatar wojciechbulaty commented on July 19, 2024

When I said "a fix" I probably should have said "a working temporary workaround" :) What I have done is I am encoding the URL if it cannot be parsed by URI.create wherever it is called.

    private static CharSequence reEncode(String s) {
        try {
            return URLEncoder.encode(URLDecoder.decode(s, UTF_8), UTF_8);
        } catch (UnsupportedEncodingException e) {
            throw new IllegalArgumentException(s);
        }
    }

    public static String reEncodeParametersIfNeeded(String url) {
        try {
            return URI.create(url).toString();
        } catch (IllegalArgumentException e) {
            String reEncodedUrl = reEncodeParameters(url);
            notifier().info("Could not parse URL " + url + " because of " + e.getMessage() + ". ReEncoded url from " + url + " to " + reEncodedUrl);
            return reEncodedUrl;
        }
    }

from wiremock.

pupattan avatar pupattan commented on July 19, 2024

Hey,

I am facing the same issue while using standalone jar file .
Is the there any workaround or fix for the same ?

HTTP ERROR: 500

Problem accessing /api/resource[name]/data. Reason:

java.lang.IllegalArgumentException: (GET /api/resource[name]/data)@2014851095 wiremock.org.eclipse.jetty.server.Request@78183017 does not have a getUri or getHttpURI method

Powered by Jetty://

Thanks

from wiremock.

tomakehurst avatar tomakehurst commented on July 19, 2024

See #713

from wiremock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.