osglworks / java-http Goto Github PK
View Code? Open in Web Editor NEWsome common http utilities
License: Artistic License 2.0
some common http utilities
License: Artistic License 2.0
as title
This method returns accept format resolved directly from Accept
http header
So the framework using osgl-http could implement their own Current state provider to provide the thread local variable for
H.Session
H.Flash
H.Request
H.Response
At the moment */*
has been resolved to H.Format.HTML
At the moment text/css
is parsed as UNKNOWN
.
true
true
in prod mode, false
in dev mode/
Content-Security-Policy is a web security standard originated from same origin policy to prevent cross site scripting attack.
This request is to add Content-Security-Policy
into H.Header
constant definition list
as title
Update POM file to add quality control to the maven build process
as title
For Accept=image/webp,image/apng,image/*,*/*;q=0.8
request it resolves to H.Format.unknown
, which is not correct.
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);
}
The H.Context
interface is used to encapsulate the context data needed for HTTP processing logic. It shall provides the following data:
It looks like there is no big performance benefit here and makes the usage of the utility a bit cumbersome
These methods could help to create an auto increment counter cookie for app.
The session cache instance shall always be fetched through HttpConfig
. Otherwise it might lead to issue like actframework/actframework#1330
Previously if outputStream is created then it will raise IllegalStateException
if app tried to create writer
or output
.
The change will make it use adapted class to wrap existing outputstream, and the same for writer and output.
as title
So it is super easy for developer to add a cookie to current response.
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
as title
as title
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
Add _UNKNOWN_
to H.Method enum
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()
At the moment H.Response.header(String name, String value)
method is used to set the header. This request is to add the new API on H.Response
to accept header setting through H.Header
typed instance
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
as title
add public Output output()
method to H.Response
.
This is to support actframework/actframework#539
Provides API to support HTTP client operations including GET, POST, PUT, DELETE etc
There are certain browsers send out unacceptable Accept header by default.
This is to improve osgl tool's capability to deal with these funky browsers.
Refer: https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation/List_of_default_Accept_values
This enhancement can fix this issue reported in ActFramework:
actframework/actframework#1260
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
As title. Also it shall not output 443
when sending to port 443
as they are all standard port
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.