基本元素:

1.1 Http Message

一般消息包括消息头和消息体,从几个基本的学起

  http request message

HttpRequest request = new BasicHttpRequest("GET", "/",HttpVersion.HTTP_1_1);System.out.println(request.getRequestLine().getMethod());
System.out.println(request.getRequestLine().getUri());
System.out.println(request.getProtocolVersion());
System.out.println(request.getRequestLine().toString());

  http response message

HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,HttpStatus.SC_OK, "OK");System.out.println(response.getProtocolVersion());
System.out.println(response.getStatusLine().getStatusCode());
System.out.println(response.getStatusLine().getReasonPhrase());
System.out.println(response.getStatusLine().toString());

  对于消息头的处理

HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,HttpStatus.SC_OK, "OK");
response.addHeader("Set-Cookie","c1=a; path=/; domain=localhost");
response.addHeader("Set-Cookie","c2=b; path=\"/\", c3=c; domain=\"localhost\"");
Header h1 = response.getFirstHeader("Set-Cookie");
System.out.println(h1);
Header h2 = response.getLastHeader("Set-Cookie");
System.out.println(h2);
Header[] hs = response.getHeaders("Set-Cookie");
System.out.println(hs.length);

  如何获得对应的properties

HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,HttpStatus.SC_OK, "OK");
response.addHeader("Set-Cookie","c1=a; path=/; domain=localhost");
response.addHeader("Set-Cookie","c2=b; path=\"/\", c3=c; domain=\"localhost\"");HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator("Set-Cookie"));while (it.hasNext()) {HeaderElement elem = it.nextElement();System.out.println(elem.getName() + " = " + elem.getValue());NameValuePair[] params = elem.getParameters();for (int i = 0; i < params.length; i++) {System.out.println(" " + params[i]);}
}

  消息体

HttpCore区分三种消息体,streamed(流),通常流式的消息是不能重复的, self-contained:内容从内存中获得,或者通过方法获得,这种消息通常是可以重复的。 wrapping,从其他的entity中获得。一个消息可以重复,意味着可以被多次读取,通常这种消息是ByteArrayEntity和StringEntity。说了这么多,怎么使用Http Entity呢?

StringEntity myEntity = new StringEntity("important message","UTF-8");System.out.println(myEntity.getContentType());
System.out.println(myEntity.getContentLength());
System.out.println(EntityUtils.getContentCharSet(myEntity));
System.out.println(EntityUtils.toString(myEntity));
System.out.println(EntityUtils.toByteArray(myEntity).length);

  特别的,我们对消息的读取完成需要释放对应的通道。

HttpResponse response;
HttpEntity entity = response.getEntity();
if (entity != null) {InputStream instream = entity.getContent();try {// do something useful} finally {instream.close();}
}

  下面列举了HttpCore支持的Entity和如何创建他们。

BasicHttpEntity

BasicHttpEntity myEntity = new BasicHttpEntity();
myEntity.setContent(someInputStream);
myEntity.setContentLength(340); // sets the length to 340

StringEntity

StringBuilder sb = new StringBuilder();
Map<String, String> env = System.getenv();
for (Entry<String, String> envEntry : env.entrySet()) {sb.append(envEntry.getKey()).append(": ").append(envEntry.getValue()).append("\n");
}// construct without a character encoding (defaults to ISO-8859-1)
HttpEntity myEntity1 = new StringEntity(sb.toString());// alternatively construct with an encoding (mime type defaults to "text/plain")
HttpEntity myEntity2 = new StringEntity(sb.toString(), "UTF-8");// alternatively construct with an encoding and a mime type
HttpEntity myEntity3 = new StringEntity(sb.toString(), "text/html", "UTF-8");

InputStreamEntity

InputStream instream = getSomeInputStream();
InputStreamEntity myEntity = new InputStreamEntity(instream, 16);

FileEntity

HttpEntity entity = new FileEntity(staticFile,"application/java-archive");

HttpEntityWrapper

这个是简历WrapperEntity的基类,我们要实现其中的方法。

BufferedHttpEntity

是HttpEntityWrapper的子类,从提供的Entity中读取内容。

myNonRepeatableEntity.setContent(someInputStream);
BufferedHttpEntity myBufferedEntity = new BufferedHttpEntity(myNonRepeatableEntity);

介绍完message和entity,我们学习http connection

HttpConnection

httpconnection 负责http消息的序列化和反序列化,通常极少直接使用http connection,我们有更高一层的协议。并且,谨记,http connection是非线程安的。最好将http connection整合到一个线程中。

1.2http connection不提供完整的配置对与打开http connection,因为通常这个过程很负责,特别是在客户端的时候。那我们通常是和通过绑定到对应的socket来完成这个过程的。

通常我们这样使用

客户端

Socket socket = new Socket();
// Initialize socket
HttpParams params = new BasicHttpParams();
DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
conn.bind(socket, params);
HttpRequest request = new BasicHttpRequest("GET", "/");
conn.sendRequestHeader(request);
HttpResponse response = conn.receiveResponseHeader();
conn.receiveResponseEntity(response);
HttpEntity entity = response.getEntity();
if (entity != null) {// Do something useful with the entity and, when done, ensure all// content has been consumed, so that the underlying connection// can be re-usedEntityUtils.consume(entity);
}

服务器端

Socket socket = new Socket();
// Initialize socket
HttpParams params = new BasicHttpParams();
DefaultHttpServerConnection conn = new DefaultHttpServerConnection();
conn.bind(socket, params);
HttpRequest request = conn.receiveRequestHeader();
if (request instanceof HttpEntityEnclosingRequest) {conn.receiveRequestEntity((HttpEntityEnclosingRequest) request);HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();if (entity != null) {// Do something useful with the entity and, when done, ensure all// content has been consumed, so that the underlying connection// could be re-usedEntityUtils.consume(entity);}
}
HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,200, "OK");
response.setEntity(new StringEntity("Got it"));
conn.sendResponseHeader(response);
conn.sendResponseEntity(response);

怎么通过IO和处理这些entity,我们通过conn.receiveRequestEntity和conn.receiveResponseEntity不会buffer data或者检索data,对于其中内容的获得,我们需要用HttpEntity.getContent()来获得,而这个过程会自动编码我们的内容。通过HttpEntity.writeTo(outputStream)来生成输出的信息

三种内容传输机制

Content-Length根据长度

Identity coding 一直传输到结束

Chunk coding数据块的方式传送

怎么关掉http connection

或者通过connection.close(),或者通过connection.shutdown()

httpConnection异常

IOException 和ProtocolException

Http protocol processors

可以认为http protocol processors是如果http interceptor的链,对应的设计模式是装饰模式。通常的http interceptors需要线程安全的方式来实现,这个和servlet一样,不应该有实体类。

几个标准的Standard protocol interceptors

RequestContent

ResponseContent

这两个限制长度

RequestConnControl ResponseConnControl负责connection header

RequestDate ResponseDate Date header

RequestExpectContinue  expect-continue handshake

RequestTargetHost

RequestUserAgent

ResponseServer

使用的例子

BasicHttpProcessor httpproc = new BasicHttpProcessor();
// Required protocol interceptors
httpproc.addInterceptor(new RequestContent());
httpproc.addInterceptor(new RequestTargetHost());
// Recommended protocol interceptors
httpproc.addInterceptor(new RequestConnControl());
httpproc.addInterceptor(new RequestUserAgent());
httpproc.addInterceptor(new RequestExpectContinue());HttpContext context = new BasicHttpContext();HttpRequest request = new BasicHttpRequest("GET", "/");
httpproc.process(request, context);
HttpResponse response = null;
Send the request to the target host and get a response.
httpproc.process(response, context);

几个连接器可以通过http context 来进行数据的交换

BasicHttpProcessor httpproc = new BasicHttpProcessor();
httpproc.addInterceptor(new HttpRequestInterceptor() {public void process(HttpRequest request,HttpContext context) throws HttpException, IOException {String id = (String) context.getAttribute("session-id");if (id != null) {request.addHeader("Session-ID", id);}}});
HttpRequest request = new BasicHttpRequest("GET", "/");
httpproc.process(request, context);

两个context可以合成一个

HttpContext parentContext = new BasicHttpContext();
parentContext.setAttribute("param1", Integer.valueOf(1));
parentContext.setAttribute("param2", Integer.valueOf(2));HttpContext localContext = new BasicHttpContext();
localContext.setAttribute("param2", Integer.valueOf(0));
localContext.setAttribute("param3", Integer.valueOf(3));
HttpContext stack = new DefaultedHttpContext(localContext,parentContext);System.out.println(stack.getAttribute("param1"));
System.out.println(stack.getAttribute("param2"));
System.out.println(stack.getAttribute("param3"));
System.out.println(stack.getAttribute("param4"));

Http parameters

http parameters 大多数情况下和http context类似,但是目的不同,http params用于存储简单的数据,而http context用于大数据的处理,一个使用的例子

HttpParams parentParams = new BasicHttpParams();
parentParams.setParameter(CoreProtocolPNames.PROTOCOL_VERSION,HttpVersion.HTTP_1_0);
parentParams.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET,"UTF-8");HttpParams localParams = new BasicHttpParams();
localParams.setParameter(CoreProtocolPNames.PROTOCOL_VERSION,HttpVersion.HTTP_1_1);
localParams.setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE,Boolean.FALSE);
HttpParams stack = new DefaultedHttpParams(localParams,parentParams);System.out.println(stack.getParameter(CoreProtocolPNames.PROTOCOL_VERSION));
System.out.println(stack.getParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET));
System.out.println(stack.getParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE));
System.out.println(stack.getParameter(CoreProtocolPNames.USER_AGENT));

Http parameter beans

通过java bean的方式使用

HttpParams params = new BasicHttpParams();
HttpProtocolParamBean paramsBean = new HttpProtocolParamBean(params);
paramsBean.setVersion(HttpVersion.HTTP_1_1);
paramsBean.setContentCharset("UTF-8");
paramsBean.setUseExpectContinue(true);System.out.println(params.getParameter(CoreProtocolPNames.PROTOCOL_VERSION));
System.out.println(params.getParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET));
System.out.println(params.getParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE));
System.out.println(params.getParameter(CoreProtocolPNames.USER_AGENT));

Blocking HTTP protocol handlers

Http Service 是服务器端用阻塞机制实现的消息处理的类。

HttpParams params;
// Initialize HTTP parameters
HttpProcessor httpproc;
// Initialize HTTP processorHttpService httpService = new HttpService(httpproc,new DefaultConnectionReuseStrategy(),new DefaultHttpResponseFactory());
httpService.setParams(params);

Http request handlers主要用于生成对给定request的响应

HttpRequestHandler myRequestHandler = new HttpRequestHandler() {public void handle(HttpRequest request,HttpResponse response,HttpContext context) throws HttpException, IOException {response.setStatusCode(HttpStatus.SC_OK);response.addHeader("Content-Type", "text/plain");response.setEntity(new StringEntity("some important message"));}};

Request handler resolver 主要用于管理http request handlers。例子

HttpService httpService;
// Initialize HTTP serviceHttpRequestHandlerRegistry handlerResolver =new HttpRequestHandlerRegistry();
handlerReqistry.register("/service/*", myRequestHandler1);
handlerReqistry.register("*.do", myRequestHandler2);
handlerReqistry.register("*", myRequestHandler3);// Inject handler resolver
httpService.setHandlerResolver(handlerResolver);

怎么用http service 来处理http request

HttpService httpService;
// Initialize HTTP service
HttpServerConnection conn;
// Initialize connection
HttpContext context;
// Initialize HTTP contextboolean active = true;
try {while (active && conn.isOpen()) {httpService.handleRequest(conn, context);}
} finally {conn.shutdown();
}

Http request executor

这个是客户端使用的,基于阻塞IO用于消息处理的类,使用例子

HttpClientConnection conn;
// Create connection
HttpParams params;
// Initialize HTTP parameters
HttpProcessor httpproc;
// Initialize HTTP processor
HttpContext context;
// Initialize HTTP contextHttpRequestExecutor httpexecutor = new HttpRequestExecutor();BasicHttpRequest request = new BasicHttpRequest("GET", "/");
request.setParams(params);
httpexecutor.preProcess(request, httpproc, context);
HttpResponse response = httpexecutor.execute(request, conn, context);
response.setParams(params);
httpexecutor.postProcess(response, httpproc, context);HttpEntity entity = response.getEntity();
EntityUtils.consume(entity);

看到这部分我终于理解了,Http Components 的官方例子ElementalHttpServer和ElementalHttpGet这些个实现的方式了。贴上官方的代码

package com.test;import java.io.File;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.util.Locale;import org.apache.http.ConnectionClosedException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.HttpServerConnection;
import org.apache.http.HttpStatus;
import org.apache.http.MethodNotSupportedException;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.FileEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.impl.DefaultHttpResponseFactory;
import org.apache.http.impl.DefaultHttpServerConnection;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.params.HttpParams;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.params.SyncBasicHttpParams;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpProcessor;
import org.apache.http.protocol.HttpRequestHandler;
import org.apache.http.protocol.HttpRequestHandlerRegistry;
import org.apache.http.protocol.HttpService;
import org.apache.http.protocol.ImmutableHttpProcessor;
import org.apache.http.protocol.ResponseConnControl;
import org.apache.http.protocol.ResponseContent;
import org.apache.http.protocol.ResponseDate;
import org.apache.http.protocol.ResponseServer;
import org.apache.http.util.EntityUtils;
/*** Basic, yet fully functional and spec compliant, HTTP/1.1 file server.* <p>* Please note the purpose of this application is demonstrate the usage of HttpCore APIs.* It is NOT intended to demonstrate the most efficient way of building an HTTP file server.***/
public class ElementalHttpServer {public static void main(String[] args) throws Exception {if (args.length < 1) {System.err.println("Please specify document root directory");System.exit(1);}     //开启一个线程进行http connection的管理Thread t = new RequestListenerThread(8080, args[0]);t.setDaemon(false);t.start();}static class HttpFileHandler implements HttpRequestHandler  {private final String docRoot;public HttpFileHandler(final String docRoot) {super();this.docRoot = docRoot;}//进行相应的处理public void handle(final HttpRequest request,final HttpResponse response,final HttpContext context) throws HttpException, IOException {String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);if (!method.equals("GET") && !method.equals("HEAD") && !method.equals("POST")) {throw new MethodNotSupportedException(method + " method not supported");}String target = request.getRequestLine().getUri();if (request instanceof HttpEntityEnclosingRequest) {HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();byte[] entityContent = EntityUtils.toByteArray(entity);System.out.println("Incoming entity content (bytes): " + entityContent.length);}final File file = new File(this.docRoot, URLDecoder.decode(target, "UTF-8"));if (!file.exists()) {response.setStatusCode(HttpStatus.SC_NOT_FOUND);StringEntity entity = new StringEntity("<html><body><h1>File" + file.getPath() +" not found</h1></body></html>",ContentType.create("text/html", "UTF-8"));response.setEntity(entity);System.out.println("File " + file.getPath() + " not found");} else if (!file.canRead() || file.isDirectory()) {response.setStatusCode(HttpStatus.SC_FORBIDDEN);StringEntity entity = new StringEntity("<html><body><h1>Access denied</h1></body></html>",ContentType.create("text/html", "UTF-8"));response.setEntity(entity);System.out.println("Cannot read file " + file.getPath());} else {response.setStatusCode(HttpStatus.SC_OK);FileEntity body = new FileEntity(file, ContentType.create("text/html", (Charset) null));response.setEntity(body);System.out.println("Serving file " + file.getPath());}}}static class RequestListenerThread extends Thread {private final ServerSocket serversocket;private final HttpParams params;private final HttpService httpService;public RequestListenerThread(int port, final String docroot) throws IOException {//创建server socket用于banding,初始化params,一些链接的信息       this.serversocket = new ServerSocket(port);this.params = new SyncBasicHttpParams();this.params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000).setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024).setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false).setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true).setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1");// Set up the HTTP protocol processor 创建一些拦截器HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {new ResponseDate(),new ResponseServer(),new ResponseContent(),new ResponseConnControl()});// Set up request handlers 服务器端用 httpRequestHandlerRegistry来管理对应的httphandler。我们这里将所有的请求都用 HttpFileHandler来进行处理。HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();reqistry.register("*", new HttpFileHandler(docroot));// Set up the HTTP service 关键一个http servicethis.httpService = new HttpService(httpproc,new DefaultConnectionReuseStrategy(),new DefaultHttpResponseFactory(),reqistry,this.params);}@Overridepublic void run() {System.out.println("Listening on port " + this.serversocket.getLocalPort());while (!Thread.interrupted()) {try {// Set up HTTP connection 监听来自客户端的请求。并建立连接。单独开一个线程来进行处理这个连接。Socket socket = this.serversocket.accept();DefaultHttpServerConnection conn = new DefaultHttpServerConnection();System.out.println("Incoming connection from " + socket.getInetAddress());conn.bind(socket, this.params);// Start worker threadThread t = new WorkerThread(this.httpService, conn);t.setDaemon(true);t.start();} catch (InterruptedIOException ex) {break;} catch (IOException e) {System.err.println("I/O error initialising connection thread: "+ e.getMessage());break;}}}}static class WorkerThread extends Thread {private final HttpService httpservice;private final HttpServerConnection conn;public WorkerThread(final HttpService httpservice,final HttpServerConnection conn) {super();this.httpservice = httpservice;this.conn = conn;}@Overridepublic void run() {System.out.println("New connection thread");HttpContext context = new BasicHttpContext(null);try {while (!Thread.interrupted() && this.conn.isOpen()) {            //这个连接要处理的事情,就是处理这个request。根据我们注册的httprequesthandler来找对应的处理的handler,这里都会转到httpfilehandler。并调用他的handler方法this.httpservice.handleRequest(this.conn, context);}} catch (ConnectionClosedException ex) {System.err.println("Client closed connection");} catch (IOException ex) {System.err.println("I/O error: " + ex.getMessage());} catch (HttpException ex) {System.err.println("Unrecoverable HTTP protocol violation: " + ex.getMessage());} finally {try {this.conn.shutdown();} catch (IOException ignore) {}}}}}

最后根据阅读的成果和原来的代码,我实现了简单的HttpServer,这个是一个httpserver的主要的部分,2个线程类,一个requesthandler就可以实现。

package com.test;import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.HttpServerConnection;
import org.apache.http.HttpStatus;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.impl.DefaultHttpResponseFactory;
import org.apache.http.impl.DefaultHttpServerConnection;
import org.apache.http.params.HttpParams;
import org.apache.http.params.SyncBasicHttpParams;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpProcessor;
import org.apache.http.protocol.HttpRequestHandler;
import org.apache.http.protocol.HttpRequestHandlerRegistry;
import org.apache.http.protocol.HttpService;
import org.apache.http.protocol.ImmutableHttpProcessor;
import org.apache.http.protocol.ResponseConnControl;
import org.apache.http.protocol.ResponseContent;
import org.apache.http.protocol.ResponseDate;
import org.apache.http.protocol.ResponseServer;import sun.java2d.pipe.SpanClipRenderer;public class MyHttpServer {public static void main(String args[]) throws Exception {RequestListenerThread athread = new RequestListenerThread(8086);athread.start();}  static class HttpFileHandler implements HttpRequestHandler {public HttpFileHandler(){super();}@Overridepublic void handle(HttpRequest request, HttpResponse response, HttpContext context)throws HttpException, IOException {// TODO Auto-generated method stubSystem.out.println("yes success in httpfilehandler!");response.setStatusCode(HttpStatus.SC_NOT_FOUND);StringEntity entity = new StringEntity("<html><body><h1>File"  +" not found</h1></body></html>",ContentType.create("text/html", "UTF-8"));response.setEntity(entity);}}static class WorkThread extends Thread{private final HttpService httpservice;private final HttpServerConnection conn;public WorkThread(final HttpService service,final HttpServerConnection conn){super();this.httpservice = service;this.conn = conn;}@Overridepublic void run(){System.out.println("New connection created!");HttpContext context = new BasicHttpContext(null);try{while(!Thread.interrupted()&&conn.isOpen()){System.out.println("handler request!");this.httpservice.handleRequest(this.conn, context);Thread.sleep(3000);}}catch (Exception e) {// TODO: handle exceptione.printStackTrace();}finally{try{System.out.println("server shutdown begin!");this.conn.shutdown();System.out.println("server shutdown end!");}catch (Exception e) {// TODO: handle exceptione.printStackTrace();}}}}static class RequestListenerThread extends Thread {private final ServerSocket socket;private final HttpParams params;private final HttpService service;public RequestListenerThread(int port) throws Exception {this.socket = new ServerSocket(port);// paramsthis.params = new SyncBasicHttpParams();// processcorsHttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] { new ResponseDate(),new ResponseServer(), new ResponseContent(),new ResponseConnControl() });// request hanlder registersHttpRequestHandlerRegistry registry = new HttpRequestHandlerRegistry();registry.register("*", new HttpFileHandler());// set up http servicethis.service = new HttpService(httpproc, new DefaultConnectionReuseStrategy(),new DefaultHttpResponseFactory(),registry,this.params);}@Overridepublic void run() {System.out.println("listening on port " + socket.getLocalPort());while (!Thread.interrupted()) {try {Socket soc = this.socket.accept();System.out.println("a client try to connect");DefaultHttpServerConnection conn = new DefaultHttpServerConnection();conn.bind(soc, this.params);//开启一个线程来负责通讯Thread worker = new WorkThread(this.service, conn);worker.setDaemon(true);worker.start();} catch (Exception e) {break;}}}}}

  

下一部分,我们要对NIO非阻塞的方式进行翻译和学习

转载于:https://www.cnblogs.com/snail-tomorrow/archive/2013/02/20/2918347.html

Http Core学习(Http Components 翻译和学习)相关推荐

  1. 【YOLO系列】YOLOv1论文超详细解读(翻译 +学习笔记)

    前言 从这篇开始,我们将进入YOLO的学习.YOLO是目前比较流行的目标检测算法,速度快且结构简单,其他的目标检测算法如RCNN系列,以后有时间的话再介绍. 本文主要介绍的是YOLOV1,这是由以Jo ...

  2. Elastic Nodes Example 翻译及学习整理

    文章目录 Elastic Nodes Example 翻译及学习整理 题记: 简介: Node Class Definition Edge Class Definition GraphWidget C ...

  3. nlp论文-《Neural Machine Translation by Jointly Learning to Align and Translate》-基于联合学习对齐和翻译的神经机器翻译(二)

    1.论文整体框架 1.1 摘要 神经机器翻译的任务定义: 传统神经机器翻译所用的编码器-解码器模型的缺陷: 本文提出一种能够自动搜索原句中与预测目标词相关的神经机器翻译模型: 所提出的模型的效果: 1 ...

  4. nlp论文-《Neural Machine Translation by Jointly Learning to Align and Translate》-基于联合学习对齐和翻译的神经机器翻译(一)

    <Neural Machine Translation by Jointly Learning to Align and Translate>--基于联合学习对齐和翻译的神经机器翻译 作者 ...

  5. 经典神经网络论文超详细解读(三)——GoogLeNet InceptionV1学习笔记(翻译+精读+代码复现)

    前言 在上一期中介绍了VGG,VGG在2014年ImageNet 中获得了定位任务第1名和分类任务第2名的好成绩,而今天要介绍的就是同年分类任务的第一名--GoogLeNet . 作为2014年Ima ...

  6. 经典神经网络论文超详细解读(八)——ResNeXt学习笔记(翻译+精读+代码复现)

    前言 今天我们一起来学习何恺明大神的又一经典之作: ResNeXt(<Aggregated Residual Transformations for Deep Neural Networks&g ...

  7. 【论文翻译】联合学习对齐和翻译的神经机器翻译

    这篇论文在采用RNN编码器-解码器结构做端到端的神经机器翻译的基础上,使得模型可以在预测下一个词的时候,自动地搜索源句子相关的部分,这就是attention机制. 原论文链接: Neural Mach ...

  8. 《A Survey on Transfer Learning》迁移学习研究综述 翻译

    迁移学习研究综述 Sinno Jialin Pan and Qiang Yang,Fellow, IEEE 摘要:   在许多机器学习和数据挖掘算法中,一个重要的假设就是目前的训练数据和将来的训练数据 ...

  9. Android Jetpack Components of LiveData 学习笔记

    Android Jetpack Components of Lifecycle 学习笔记 Android Jetpack Components of LiveData 学习笔记 Android Jet ...

  10. 【ASP.NET Core Web API 6.0 基础学习】

    ASP.NET Core Web API 6.0 基础学习 半夏创建Web Api 6.0教程 返回时间格式化 Swagger注释和版本控制 使用appsetting.json的数据 IOC注入,使用 ...

最新文章

  1. 众多支持者助力BCH第二次硬分叉升级
  2. 非洲儿童(南阳oj1036)(馋)
  3. Asp.net 2.0 制作复合控件示例(二)[示例代码下载]
  4. 这么写注释,老板会不会开除我?
  5. javaWeb服务详解(含源代码,测试通过,注释)
  6. centos7.3 安装 mysql-5.7.13
  7. 印度朋友手把手教你学Scala(10):Scala里的样本对象
  8. java jmap mat_利用jmap和MAT等工具查看JVM运行时堆内存
  9. 题目552-小数阶乘-nyoj20140811
  10. [RocketMQ]消息中间件—RocketMQ消息消费(一)
  11. 车载系统不识别 U盘
  12. 【笔记】Android.mk编译apk不生成ota包或者odex包
  13. FastDFS安装手册
  14. RT-Thread Studio网络应用MQTT笔记
  15. 计算机网络五层模型(ing)
  16. 微信小程序之CSS实现图片遮罩
  17. cyberduck 源代码学习记录一,编译源代码 build for window
  18. Python while语句2021-08-27
  19. 程序员噩梦typescript+vue3
  20. Android开发添加QQ群 跳到QQ聊天页面

热门文章

  1. centos7中Python切换到Python3.x版本(解决常出现的错误)
  2. 压力测试网站_JMeter简单压力测试教程
  3. 蓝桥杯2016年第七届C++省赛B组第一题-煤球数目
  4. Git — 解决“requested upstream branch ‘origin/master‘ does not exist“
  5. Flutter学习 — 使用WebSockets
  6. ubuntu执行configure配置代码出现unable to guess system type报错
  7. HDMI热插拔检测原理
  8. ftl转pdf及问题集锦
  9. centos7.2 kvm 安装超详细
  10. 涨姿势系列之——内核环境下花式获得CSRSS进程id