Created
May 29, 2014 07:23
-
-
Save NiteshKant/d15cfc022099c82d8fe4 to your computer and use it in GitHub Desktop.
Http 1.0 Server used for Apache Bench
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2014 Netflix, Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*/ | |
package io.reactivex.netty.examples.java; | |
import io.netty.buffer.ByteBuf; | |
import io.netty.handler.codec.http.HttpHeaders; | |
import io.netty.handler.logging.LogLevel; | |
import io.reactivex.netty.protocol.http.server.HttpServerBuilder; | |
import io.reactivex.netty.protocol.http.server.HttpServerRequest; | |
import io.reactivex.netty.protocol.http.server.HttpServerResponse; | |
import io.reactivex.netty.protocol.http.server.RequestHandler; | |
import rx.Observable; | |
public final class Http10Server { | |
public static final String MSG = "Hello World"; | |
public static final int HELLO_WORLD_LENGTH = MSG.getBytes().length; | |
public static void main(String[] args) { | |
new HttpServerBuilder<ByteBuf, ByteBuf>(7008, new RequestHandler<ByteBuf, ByteBuf>() { | |
@Override | |
public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) { | |
response.getHeaders().set(HttpHeaders.Names.CONTENT_LENGTH, HELLO_WORLD_LENGTH); | |
return response.writeStringAndFlush(MSG); | |
} | |
}, true).enableWireLogging(LogLevel.DEBUG).build().startAndWait(); | |
} | |
} |
AB command used for the test was:
ab -k -n 1 -c 1 'http://127.0.01:7008/hello'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Change this:
to
to enable wire level logs for the server.