| Age | Commit message (Collapse) | Author |
|
With help of spdxconv tool [1], we able to bulk update all files license
and copyright format to comply with SPDX formats.
[1] https://kilabit.info/project/spdxconv/
|
|
Instead of annotating the lines that caught by linters, fix it to comply
with the recommendations.
This causes several breaking changes, especially related to naming,
* api/slack: [Message.IconUrl] become [Message.IconURL]
* lib/dns: DefaultSoaMinumumTtl become DefaultSoaMinimumTTL
* lib/email: [Message.SetBodyHtml] become [Message.SetBodyHTML]
* lib/http: [Client.GenerateHttpRequest] become
[Client.GenerateHTTPRequest]
* lib/http: [ClientOptions.ServerUrl] become [ClientOptions.ServerURL]
* lib/http: [EndpointRequest.HttpWriter] become
[EndpointRequest.HTTPWriter]
* lib/http: [EndpointRequest.HttpRequest] become
[EndpointRequest.HTTPRequest]
* lib/http: [ServerOptions.EnableIndexHtml] become
[ServerOptions.EnableIndexHTML]
* lib/http: [SSEConn.HttpRequest] become [SSEConn.HTTPRequest]
* lib/smtp: [ClientOptions.ServerUrl] become [ClientOptions.ServerURL]
* lib/ssh/sftp: [FileAttrs.SetUid] become [FileAttrs.SetUID]
* lib/ssh/sftp: [FileAttrs.Uid] become [FileAttrs.UID]
|
|
There are several reasons that why we move from github.com.
First, related to the name of package.
We accidentally name the package with "share" a common word in English
that does not reflect the content of repository.
By moving to other repository, we can rename it to better and unique
name, in this "pakakeh.go".
Pakakeh is Minang word for tools, and ".go" suffix indicate that the
repository related to Go programming language.
Second, supporting open source.
The new repository is hosted under sourcehut.org, the founder is known
to support open source, and all their services are licensed under AGPL,
unlike GitHub that are closed sources.
Third, regarding GitHub CoPilot.
The GitHub Terms of Service [1], allow any public content that are hosted
there granted them to parse the content.
On one side, GitHub helps and flourish the open source, but on another
side have an issues regarding scraping the copyleft license [2].
[1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us
[2]: https://githubcopilotinvestigation.com
|
|
|
|
The path package provide a new type Route, detached from "lib/http".
A Route represent a parsed path.
A path can have a key, or binding, that can be replaced with string
value.
For example, "/org/:user/:repo" have two keys "user" and "repo".
Route handle the path in case-insensitive manner.
|
|
If the node modification time is less than requested time value in
request header If-Modified-Since, server will response with
304 Not Modified.
|
|
While at it, group the constants by its values.
|
|
|
|
When server receive,
GET /big
Range: bytes=0-
and the requested resources is quite larger, where writing all content of
file result in i/o timeout, it is best practice [1][2] if the server
write only partial content and let the client continue with the
subsequent Range request.
In the above case, the server should response with,
HTTP/1.1 206 Partial content
Content-Range: bytes 0-<limit>/<size>
Content-Length: <limit>
Where limit is maximum packet that is reasonable [3] for most of the
client.
In this server we choose 8MB as limit.
[1]: https://stackoverflow.com/questions/63614008/how-best-to-respond-to-an-open-http-range-request
[2]: https://bugzilla.mozilla.org/show_bug.cgi?id=570755
[3]: https://docs.aws.amazon.com/whitepapers/latest/s3-optimizing-performance-best-practices/use-byte-range-fetches.html
|
|
There are some reports that I disagree with revive, in example, code
should not declare the type after variables.
In my opinion, on some cases, declaring the type make the code more
readable and explicit.
Since I did not want to add new configuration file, we changes it and
follow revive for now.
|
|
For server SSE, we add new type SSEEndpoint, for registering endpoint
that can handle SSE.
For client SSE, we add it in new sub package "sseclient".
Implements: https://todo.sr.ht/~shulhan/share/1
Implements: https://todo.sr.ht/~shulhan/share/2
Signed-off-by: Shulhan <ms@kilabit.info>
|
|
|
|
The ParseMultipartRange parse the multipart/byteranges body or response
from HTTP Range request.
Each Content-Range position and body part in the multipart will be stored
under RangePosition.
|
|
For HTTP Server using HandleFS, the Range request is handled
automatically.
For other HTTP server, user can use the HandleRange function.
The HandleRange function handle [HTTP Range] request using "bytes" unit.
The body parameter contains the content of resource being requested that
accept Seek method.
If the Request method is not GET, or no Range in header request it will
return all the body [RFC7233 S-3.1].
The contentType is optional, if its empty, it will detected by
http.ResponseWriter during Write.
[HTTP Range]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests
[RFC7233 S-3.1]: https://datatracker.ietf.org/doc/html/rfc7233#section-3.1
# Conflicts:
# CHANGELOG.adoc
|
|
|
|
Since Go 1.16, the ioutil package has been deprecated.
This changes replace any usage that use functions from ioutil package
with their replacement from package os or package io.
|
|
The Download method get a resource from remote server and write it into
DownloadRequest.Output (a io.Writer).
|
|
This will allow calling setHeaders without instance of Client.
|
|
If the Server handle file system using MemFS, server will set the
ETag [1] header using the file epoch as value.
On the next request, server will compare the request header
If-None-Match with the requested file epoch. If its equal server will
return the response as 304 StatusNotModified.
[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
|
|
|
|
Change the Callback and ErrorCallbackHandler parameter to EndpointRequest.
|
|
The "Bearer" string is not in the header key but in the value of
"Authorization".
While at it, add HTTP header names for "Host" and "Cookie".
|
|
Previously, the IPAddressOfRequest accept only one parameter, the
http.Request. This make the function only works on HTTP server from
standard library, not from other library (for example websocket) or
other protocol that use HTTP header too.
This commit changes the parameter to http.Header and default address.
If no headers present, then the default address will be used.
|
|
The IPAddressOfRequest get the client IP address from HTTP request header
"X-Real-IP" or "X-Forwarded-For" or from Request.RemoteAddr, which ever
non-empty first.
The ParseXForwardedFor parse the HTTP header "X-Forwarded-For" value from
the following format "client, proxy1, proxy2" into client address and
list of proxy addressess.
|
|
Since both of those constants are used only for HTTP header, it could
be more clear if we prefix it with "Header".
Also, rename "HeaderAuthKeyBearer" to "HeaderBearer" and sort the list
of header constants.
|
|
The Summary section contains pseudocode that illustrate how Endpoint,
Callback, and CallbackErrorHandler works when the Server receive HTTP
request.
Its provide an overview of how everythins connected in Server.
|
|
The RegisterXxx methods on Server has been replaced with single method,
RegisterEndpoint.
|
|
|
|
The new field ErrorHandler on Endpoint allow the implementor to define
their own function to handler error from Endpoint.Call.
If the ErrorHandler is nil it will default to DefaultErrorHandler.
|
|
|
|
The list of origin and headers are set on ServerOptions. Once their
set, any OPTIONS request with Access-Control-Request-Method and/or
Accces-Control-Request-Headers will be automatically check and responsed
with apropriate white list.
|
|
|
|
If the content-type of response body from server is text or JSON and
Content-Encoding is one of the compression methods (bzip2, compress,
deflate, or gzip) then uncompress them before returning it to user.
|
|
|
|
|
|
|
|
Previously, only raw path can be registered on Endpoint. This changes
implement key binding using colon ":" on path. For example, registering
path "/:x/y" will bind key "x" to a string value that can be accessed on
http.Request.Form using Get method.
|
|
The ContentEncode() method encode each node's content into specific
encoding, in other words this method can be used to compress the content
of file in memory before being served or written to file.
Only file with size greater than 0 will be encoded.
List of known encoding is "gzip".
|
|
|
|
The temporary redirect use the HTTP status 307. If redirect URL is empty
then its default to root.
|
|
The ResponseWriter can be used to write custom header or to write cookies.
|
|
|
|
|
|
|