我使用Sun Ws实现编写了一个Web服务服务器,并使用HttpsServer进行发布(TLS相互身份验证).
httpServer=HttpsServer.create(...);
ssl=SSLContext.getInstance("TLS");
...
ssl.init(keyFactory.getKeyManagers(),trustFactory.getTrustManagers(),new SecureRandom());
configurator=new HttpsConfigurator(ssl) {
public void configure (HttpsParameters params)
{
SSLContext context;
SSLParameters sslparams;
context=getSSLContext();
sslparams=context.getDefaultSSLParameters();
sslparams.setNeedClientAuth(true);
params.setSSLParameters(sslparams);
}
};
((HttpsServer)httpServer).setHttpsConfigurator(configurator);
...
endPoint=getSunWsProvider().createEndPoint(...);
httpContext=httpServer.createContext(...);
endPoint.publish(httpContext);
httpServer.start();
...
Run Code Online (Sandbox Code Playgroud)
一切正常.当客户端执行Web服务的服务器端实现时,我想知道哪个客户端正在执行代码(以管理权限).知道每个客户端都有自己的证书,如何在Web服务调用之前获取用于TLS协商的客户端证书?(我更愿意找到基于客户端证书分析的解决方案,而不是为每个Web服务调用添加标识信息).
谢谢您的帮助.
我已经使用Sun的轻量级HttpServer在线发现了一个简单的HttpServer.
基本上主要功能如下:
public static void main(String[] args) throws Exception {
HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);
//Create the context for the server.
server.createContext("/", new BaseHandler());
server.setExecutor(null); // creates a default executor
server.start();
}
Run Code Online (Sandbox Code Playgroud)
我已经实现了BaseHandler接口的方法来处理Http请求并返回响应.
static class BaseHandler implements HttpHandler {
//Handler method
public void handle(HttpExchange t) throws IOException {
//Implementation of http request processing
//Read the request, get the parameters and print them
//in the console, then build a response and send it back.
}
}
Run Code Online (Sandbox Code Playgroud)
我还创建了一个通过线程发送多个请求的客户端.每个线程将以下请求发送到服务器:
HTTP://本地主机:8000/[上下文] INT ="+线程ID …
我正在尝试为node.js编写的应用程序实现一个简单的HTTP端点.我已经创建了HTTP服务器,但现在我一直在阅读请求内容主体:
http.createServer(function(r, s) {
console.log(r.method, r.url, r.headers);
console.log(r.read());
s.write("OK");
s.end();
}).listen(42646);
Run Code Online (Sandbox Code Playgroud)
请求的方法,URL和标头打印正确,但r.read()始终为NULL.我可以说这不是请求如何产生的问题,因为content-length服务器端的头大于零.
文档说 r是一个http.IncomingMessage实现可读流接口的对象,为什么它不起作用?
我使用 http 服务器托管本地文件。只需使用以下命令在我的 Mac HTTP 服务器上安装:
npm install --global http-server
Run Code Online (Sandbox Code Playgroud)
然后我使用以下命令在所需目录中启动该服务器:
http-server
Run Code Online (Sandbox Code Playgroud)
我在WIFI提供的同一局域网上有两个Android应用程序:
如何使(A)可以对(B)进行POST和GET请求?
(A)访问(B)的URL是什么样的?
谢谢大家.
我试图在我的项目目录中运行一个简单的http服务器.我需要的只是GET请求支持,所以我可以获取html/css/js/etc. 为此,我想从npm使用http-server.
我装了它 npm install http-server -g
现在我cd到我的项目文件夹,它有index.html文件,我打开终端并运行http-server
但是当我打开浏览器时http://localhost:8080/index.html- 它无法连接到主机.
我错过了什么吗?
我在使用 BaseHTTPRequestHandler 在 python3 中提供简单网页时遇到编码问题。
这是一个工作示例:
#!/usr/bin/python3
# -*- coding: utf-8 -*
from http.server import BaseHTTPRequestHandler, HTTPServer
from os import curdir, sep, remove
import cgi
HTML_FILE_NAME = 'test.html'
PORT_NUMBER = 8080
# This class will handles any incoming request from the browser
class myHandler(BaseHTTPRequestHandler):
# Handler for the GET requests
def do_GET(self):
self.path = HTML_FILE_NAME
try:
with open(curdir + sep + self.path, 'r') as f:
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(bytes(f.read(), 'UTF-8'))
return
except IOError:
self.send_error(404, 'File Not Found: %s' % …Run Code Online (Sandbox Code Playgroud) 在确定我使用ng-view时遇到的问题是由于安全原因chrome不支持跨源请求时,我一直在尝试为我的HTML文件运行本地http服务器.因此,我下载了npm http-server并尝试运行我的html代码,我收到错误消息:
Starting up http-server, serving indexTemplate.html
Available on:
http://127.0.0.1:8080
http://172.27.88.21:8080
Hit CTRL-C to stop the server
[Mon Jun 27 2016 19:48:11 GMT+0900 (KST)] "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36"
[Mon Jun 27 2016 19:48:11 GMT+0900 (KST)] "GET /" Error (404): "Not found"
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我弄清问题是什么以及如何解决它?任何建议和帮助将不胜感激!
我需要运行一个只能记录传入请求的简单HTTP服务器.
它应该记录整个请求的内容.像标题,饼干,身体....
我需要一个简单的解决方案,我可以在几分钟内运行,并将工作.
实施语言并不重要.
像查尔斯,但HTTP服务器而不是代理
注意:我不是要在这里解决实际项目中的任何问题.这个问题仅用于理解我在下面第二个实验(实验2)中看到的结果背后的原因.
这些实验使用Docker版本17.12.0-ce在macOS Terminal版本2.8上的macOS High Sierra 10.13.1上进行.
docker run带有-it选项的SimpleHTTPServer这是我的Dockerfile:
FROM python:2.7-slim
CMD ["python", "-m", "SimpleHTTPServer"]
Run Code Online (Sandbox Code Playgroud)
我构建它并使用此命令运行它:
docker build -t pyhttp .
docker run -it -p 8000:8000 pyhttp
Run Code Online (Sandbox Code Playgroud)
在另一个终端中,我使用以下命令测试容器:
curl http://localhost:8000/
Run Code Online (Sandbox Code Playgroud)
该curl命令产生预期结果:目录列表.在终端运行中docker run,我看到了这个预期的输出.
$ docker run -it -p 8000:8000 pyhttp
Serving HTTP on 0.0.0.0 port 8000 ...
172.17.0.1 - - [04/Feb/2018 10:07:33] "GET / HTTP/1.1" 200 -
Run Code Online (Sandbox Code Playgroud)
最后,按Ctrl+键停止此docker容器C.
docker run没有-it选项的SimpleHTTPServer现在我pyhttp用这个命令运行相同的图像: …
httpserver ×10
node.js ×3
http ×2
java ×2
android ×1
angularjs ×1
certificate ×1
client ×1
cors ×1
docker ×1
html ×1
http-headers ×1
httpclient ×1
httprequest ×1
logging ×1
macos ×1
npm ×1
python ×1
python-3.x ×1
sockets ×1
utf-8 ×1
web-services ×1