Coder Social home page Coder Social logo

java-http's People

Contributors

greenlaw110 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

xialinlin

java-http's Issues

H.Format enhancement

  • use String.intern() to set name and contentType
  • add isSameType(H.Format) method

Add `removeCookie` methods into `H.Response` class

Add two methods into H.Response class to allow developer quickly remove cookie(s) from response:

        /**
         * Adds the specified cookie to the response.  This method can be called
         * multiple times to add more than one cookie.
         *
         * @param cookie the Cookie to return to the client
         */
        public abstract void addCookie(H.Cookie cookie);

        /**
         * Removes cookie with given name.
         *
         * @param name the name of the cookie to be removed.
         */
        public void removeCookie(String name) {
            H.Cookie cookie = new H.Cookie(name);
            removeCookie(cookie);
        }

Add `H.Context` interface

The H.Context interface is used to encapsulate the context data needed for HTTP processing logic. It shall provides the following data:

  • Request
  • Response
  • Session
  • Flash

Allow using query parameter to override `Accept` header

This gives UI app developer a good flexibility to require data in different encoding form. For example,

GET /foo?_accept=json # return data in JSON format
GET /foo?_accept=xml # return data in XML format
GET /foo?_accept=yaml # return data in YAML format

The default parameter name is _accept. However it shall be able to use HttpConfig.acceptOverrideParamName(String) method to change the parameter name as per app requirement

Define http status int constant

At the moment we have a class H.Status defined. However it cannot be used in annotation return type, e.g. the org.osgl.mvc.annotation.ResponseStatus annotation require an int type value.

This request is to define commonly used http status as int constants to be used in annotation return types

`H.Response.writeText()` shall set `Content-Type` to `text/plaintext`

Java source code

// snippet 2.1b
@GetAction("echo/b")
public void echo_b(H.Request req, H.Response resp) {
    String message = req.paramVal("message");
    resp.writeText(message);
}

Send request to echo/b:

luog@luog-X510UQR:~/p/TEB/frameworks/Java$ http localhost:5460/s2/1/echo/b?message=abc
HTTP/1.1 200 OK
Content-Length: 3
Content-Type: text/html
Date: Tue, 24 Apr 2018 02:12:20 GMT
Server: act/1.8.7

abc

Expected Content-Type to be text/plaintext

The samething should happen for H.Response.writeJson() and `H.Response.writeHtml()

Improve content negotiation

When Accept header is application/json it can be interpreted correctly; but when Accept is changed to application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 it won't be treated as JSON

Allow get status from `H.Response`

At the moment we can set the status to a response. This request is to make it possible to retrieve the status information from a response. This is particularly designed to support logging access request and response status

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.