private Url newUrl() { return new Url() .withHostname("localhost") .withPathname("/foo") .withPort(8080) .withProtocol("http") .withSearch("foo=bar") .appendToFull("http://localhost:8080/foo?foo=bar"); } }
private void serializeUrl(final Url url) { writeFieldName("url"); jw.writeByte(OBJECT_START); writeField("full", url.getFull()); writeField("hostname", url.getHostname()); writeField("port", url.getPort()); writeField("pathname", url.getPathname()); writeField("search", url.getSearch()); writeLastField("protocol", url.getProtocol()); jw.writeByte(OBJECT_END); jw.writeByte(COMMA); }
@Test void testResetState() { final Url url = newUrl(); url.resetState(); assertThat(toJson(url)).isEqualTo(toJson(new Url())); }
@Override public void resetState() { postParams.resetState(); headers.resetState(); httpVersion = null; method = null; socket.resetState(); url.resetState(); cookies.resetState(); if (bodyBuffer != null) { charBufferPool.recycle(bodyBuffer); } bodyBuffer = null; }
public void copyFrom(Request other) { this.postParams.copyFrom(other.postParams); this.headers.copyFrom(other.headers); this.httpVersion = other.httpVersion; this.method = other.method; this.socket.copyFrom(other.socket); this.url.copyFrom(other.url); this.cookies.copyFrom(other.cookies); if (other.bodyBuffer != null) { final CharBuffer otherBuffer = other.getBodyBuffer(); final CharBuffer thisBuffer = this.withBodyBuffer(); for (int i = 0; i < otherBuffer.length(); i++) { thisBuffer.append(otherBuffer.charAt(i)); } thisBuffer.flip(); } }
private Transaction createTransactionWithRequiredValues() { Transaction t = new Transaction(mock(ElasticApmTracer.class)); t.start(TraceContext.asRoot(), null, (long) 0, ConstantSampler.of(true)); t.withType("type"); t.getContext().getRequest().withMethod("GET"); t.getContext().getRequest().getUrl().appendToFull("http://localhost:8080/foo/bar"); return t; }
request.withBodyBuffer().append("Hello World").flip(); request.getUrl() .withProtocol("https") .appendToFull("https://www.example.com/p/a/t/h?query=string#hash") .withHostname("www.example.com") .withPort(8080) .withPathname("/p/a/t/h") .withSearch("?query=string"); request.getSocket() .withEncrypted(true)
request.withBodyBuffer().append("Hello World").flip(); request.getUrl() .withProtocol("https") .appendToFull("https://www.example.com/p/a/t/h?query=string#hash") .withHostname("www.example.com") .withPort(8080) .withPathname("/p/a/t/h") .withSearch("?query=string"); request.getSocket() .withEncrypted(true)