aboutsummaryrefslogtreecommitdiff
path: root/lib/xmlrpc
AgeCommit message (Collapse)Author
11 daysall: apply go fixShulhan
2026-01-03all: use SPDX license header formatShulhan
2025-01-23all: use for-range with numericShulhan
Go 1.22 now support for-range on numeric value.
2025-01-23all: replace "interface{}" with "any"Shulhan
2024-09-04all: fix various linter warningsShulhan
While at it, temporary disable gosec due to excessive report for G115, which may be true, but may also break the current working program. We should alter and fix once we can test and make sure that it does not breaks.
2024-03-15lib/http: refactoring Client methods to return struct ClientResponseShulhan
Instead of returning three variables, [http.Response], []byte, and error, we combine the [http.Response] and []byte into single struct: ClientResponse.
2024-03-09lib/http: refactoring NewServer and NewClientShulhan
The NewServer and NewClient now accept non-pointer options, so the caller unable to modify the options once the server or client has been created.
2024-03-05all: comply with linter recommendations #3Shulhan
For HTTP server that use TLS, set the minimum TLS version and ReadHeaderTimeout to mitigate slowloris attack. For HTTP client or server that parameterize the use of InsecureSkipVerify, annotate the line with "nolint:gosec" to allow the code pass the check. Library that still use sha1, in example in DKIM and TOTP, skip the warnings by annotating the line with "nolint:gosec". A pointer variable now allocated their address before assigning its value. Any error that returned now wrapped using "%w". Also, replace error checking using [errors.Is] or [errors.As] instead of using equal or not-equal operators. In "lib/http", replace any usage of "math/rand" with "crypto/rand". Any call of [math/big.Rat.SetString] now annotated with "nolint:gosec" since its false positive, the issue has been fixed in Go >= 1.17.7. Any switch case that does not cover the rest of the possible values now handled by adding the cases or by replacing the "default" case with the rest of values.
2024-03-05all: comply with linter recommendations #2Shulhan
HTTP request now implicitly create request with context. Any false positive related to not closing HTTP response body has been annotated with "nolint:bodyclose". In the example code, use consistent "// Output:" comment format, by prefixing with single space. Any comment on code now also prefixing with single space. An error returned without variables now use [errors.New] instead of [fmt.Errorf]. Any error returned using [fmt.Errorf] now wrapped using "%w" instead of "%s". Also, replace error checking using [errors.Is] or [errors.As], instead of using equal/not-equal operator. Any statement like "x = x OP y" now replaced with "x OP= y". Also, swap statement is simplified using "x, y = y, x". Any switch statement with single case now replaced with if-condition. Any call to defer on function or program that call [os.Exit], now replaced by calling the deferred function directly. Any if-else condition now replaced with switch statement, if possible.
2024-03-05all: comply with linter recommendations #1Shulhan
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]
2024-03-02all: move the repository to "git.sr.ht/~shulhan/pakakeh.go"Shulhan
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
2023-09-14all: fix variable shadowing as reported by shadow toolShulhan
The shadow tool [1] report a variable where its name is declared twice or more, in different scope. [1] https://pkg.go.dev/golang.org/x/tools@v0.13.0/go/analysis/passes/shadow
2023-09-11lib/xmlrpc: add missing comment to exported type and methodsShulhan
2023-09-11lib/xmlrpc: realign struct for better size allocationShulhan
The realignment reduce the cost of the following struct, * Client: from 24 to 16 bytes (-8) * Response: from 64 to 48 bytes (-16) * Value: from 40 to 32 bytes (-8)
2023-05-20all: remove any usage of debug.Value in all packagesShulhan
Using global debug value for all packages turns out is not a good idea.
2023-02-25all: access embedded field or methods using the type nameShulhan
This is for clarity in the code, better to be explicit by typing where the field or methods come from.
2022-07-25lib/xmlrpc: rewrite the test using test.DataShulhan
2022-05-09all: reformat all codes using gofmt 1.19 (the Go tip)Shulhan
2022-03-21lib/xmlrpc: add method to get boolean field value on ValueShulhan
The GetFieldAsBoolean return the struct's field value by its key as bool type.
2022-03-21lib/xmlrpc: use %v to convert non-string type on GetFieldAsStringShulhan
Previously, if GetFieldAsString is called and the struct field type is not string, it will return "%s(<type>=<value>)" instead of the value in string. This commit fix this issue by using %v to convert non-string type.
2022-01-09lib/http: refactoring NewClient to accept single structShulhan
Previously, the NewClient function accept three parameters: serverURL, http.Header, and insecure. If we want to add another parameter, for example timeout it will cause changes on the function signature. To prevent this changes in the future, we change it now. The NewClient now accept single struct. While at it, we add option to set Timeout. The Timeout affect the http Transport Timeout and TLSHandshakeTimeout. The field is optional, if not set it will set to 10 seconds.
2021-10-05lib/xmlrpc: rewrite the Client connection using lib/httpShulhan
Using socket connection require reading the HTTP response header before we can process the response body. Instead of rewrite the parser, use the lib/http to send and receive the request/response.
2021-09-22lib/xmlrpc: convert the value using Sprintf on GetFieldAsStringShulhan
Previously, the GetFieldAsString will return empty string if the Value type is not string. In this commit, we force the value to be string by converted it using fmt.Sprintf.
2021-08-17lib/xmlrpc: fix missing port on NewClientShulhan
Calling net.Dial or tls.Dial on host without port will cause the following error, NewClient: Dial: dial tcp: address 10.148.0.164: missing port in address This changes fix this by always generate new host value using previous host and port values.
2021-06-05xmlrpc: check for returned ok arguments on interface conversionShulhan
This is to make sure that the returned value is not ignored with "_". While at it, remove unused global constant `boolTrue`.
2021-05-25xmlrpc: convert the uint8 and uint16 as type Integer, and Uint as DoubleShulhan
Previously, uint8 and uint16 will be converted as Double, but those types are in range of four bytes so it can still be handled by int32.
2021-05-25xmlrpc: change the Response to embed the errors.EShulhan
The errors.E contains code and message that also implement wrapping and unwrapping error, so we can use the Response as error just like in http.EndpointResponse.
2021-05-19xmlrpc: marshal the struct value ordered by namesShulhan
This is to make the Request or Response format consistent and to make test working as expected.
2021-05-19xmlrpc: set client response IsFault when StatusCode >= 400Shulhan
Previously, we set IsFault to true if the HTTP response code not equal to 200 only, which is not always correct. This commit changes it to check any status code that is greater or equal to 400.
2021-05-19xmlrpc: add method to marshal ResponseShulhan
2021-05-19xmlrpc: write the XML header when marshaling request not on clientShulhan
Previously, the XML header is added when sending the request using client. This commit changes it to write the header when marshaling the Request instance.
2021-05-19xmlrpc: replace Value field for struct with map of string and valueShulhan
Previously, for param with type "struct" is represented by slice of Member{Name,Value}. This commit changes the Value field for "struct" to a map of string and value for easily access the struct's member, without looping.
2021-05-19xmlrpc: refactoring the parser for decoding XML-RPC requestShulhan
This changes, * method to parse XML-RPC request, * change the Member field Value type to pointer to Value, * change the Request field Params type to slice of pointer of Value, * change the Response field Param type to pointer to Value, * rename the Value fields from Members to StructMembers and Values to ArrayValues
2021-03-21xmlrpc: add debug statements to print request and responseShulhan
The debug level is set minimum to 3. If its set it will print the request and response to standard output.
2021-03-14all: refactoring the test.Assert and test.AssertBench signatureShulhan
Previously, the test.Assert and test.AssertBench functions has the boolean parameter to print the stack trace of test in case its not equal. Since this parameter is not mandatory and its usually always set to "true", we remove them from function signature to simplify the call to Assert and AssertBench.
2020-06-10all: update email addressShulhan
2020-06-06all: use default linter optionsShulhan
2020-03-26all: fix and suppress linter warningsShulhan
2020-01-23xmlrpc: check for empty port number on NewClientShulhan
2020-01-20xmlprc: package for working with XML-RPCShulhan
This package provide a client library for talking with XML-RPC server.