Comments (12)
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.
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¶m1=~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¶m1=~cm_timer~¶m2=0¶m3=1080¶m5=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.
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.
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.
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.
Hi Tom , Any update on this issue as I have the same issue. OR would you suggest any work around ?
from wiremock.
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.
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.
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.
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.
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.
See #713
from wiremock.
Related Issues (20)
- xPath helper doesn't return result when XPath expression returns a single string item
- wiremock-jetty12: NullPointerException within WireMockHandlerDispatchingServlet (similar to #1224) HOT 1
- Failing while building wiremock-jre8-standalone version 2.31.0 using ./gradlew build (wiremock-jre8-standalone:2.31.0)
- Running tests in parallel with Wiremock 3.0.0 triggers random timing/concurrency issues HOT 2
- @RegisterExtension + WireMockExtension: Timing & state issues when using "static" HOT 5
- EqualsToJson has bad performance for big json with common keys occuring often HOT 17
- Handlebars helper - join
- Init / shutdown hooks for extensions
- Update org.xmlutil:xmlunit-core to Version 2.10.0 HOT 2
- Introduce a GUI for open source HOT 1
- NPE on WireMockServer.getServeEvents when using a StubRequestFilter HOT 1
- Adding more jettyAcceptors seems to do nothing besides cause thread contention. HOT 1
- align new join handlebar helper with features present in the join provided in the library, but not covered yet
- Expose args in Options so extensions can read it
- Possible memory leak ? HOT 15
- Prevent creating multiple stub mappings with the same ID HOT 1
- Support virtual threads in Jetty server for standalone deploy
- Error when proxying to a host that is only accessible via IPv6 HOT 1
- Formatted dates not in UTC
- __files created by default since v3.6.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wiremock.