TASEmulators / TASEmulators/BizHawk

HTTP in Lua scripting requires command-line initialization

Open
#3,665 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

re: APIHawk re: Lua API/scripting Request: Feature/Enhancement Waiting on dev consensus
Dominant language
C#
Stars
2.8k
Forks
468
PR merge metrics
No merged PRs in 30d

Description

Summary

When using Lua HTTP functions such as comm.httpGet and comm.httpPost, by default these give the error "HTTP was not initialized, please initialize it via the command line." I was unable to find documentation on the error message, but I was able to look into the code to figure out what command-line arguments are needed. For whatever reason, these functions require a URL to be set from the command-line. Setting these via the command-line like emuhawk --url_get=. --url_post=. resolves the error and allows the HTTP functions to work properly. It doesn't seem to matter what the URLs are set to so long as they are set. Setting them within Lua using the httpSetGetUrl and httpSetPostUrl functions also does not resolve the error, these must be set in the command line.

As of right now, this issue makes it difficult to use the built-in HTTP functionality for, say, implementing online multiplayer. If this is unintentional (I don't know why these functions would require global URLs), this is a bug and should be resolved. If it is intended to require command-line initialization for security or other reasons, that should at least be documented so developers can be aware of this limitation.

Repro
  1. Open BizHawk normally.
  2. Run a Lua script using the comm.httpGet or comm.httpPost functions.
  3. Observe the error message.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the comm.httpGet and comm.httpPost entry points and trace how --url_get and --url_post initialize HTTP. Reproduce the error with a normal BizHawk launch, then determine whether Lua initialization should work or whether the command-line requirement needs documentation; done means the intended behavior is implemented and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, lua
Domain
api, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.