Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't set response status #616

Closed
drandrewthomas opened this issue Oct 4, 2021 · 1 comment
Closed

Can't set response status #616

drandrewthomas opened this issue Oct 4, 2021 · 1 comment

Comments

@drandrewthomas
Copy link

Hi,

I'm using nanohttpd in an android project, currently using aide. I import it as a dependency in the app build.gradle:

dependencies { implementation 'org.nanohttpd:nanohttpd:2.3.1' }

I can serve text responses no problem, but if I use a response that requires me to provide a status (in this case, an input stream response to serve files in the assets folder) I always get an error about the response (fixed length and chunked) needing an istatus. So, for example, if I try this code:

Response resp; resp=newFixedLengthResponse(""); resp.setMimeType(mime); resp.setData(mbuffer); resp.setStatus(Response.Status.OK);

then I get this error:

Method 'fi.iki.elonen.NanoHTTPD.Response.setStatus(fi.iki.elonen.NanoHTTPD.Response.IStatus)' can not be applied to 'fi.iki.elonen.NanoHTTPD.Response.setStatus(fi.iki.elonen.NanoHTTPD.Response.Status)'

I've tried creating an IStatus variable and setting it to Response.Status.OK, but then I get an error because it doesn't like me setting an IStatus to a Status value. Also, the same problem happens if I do something like this instead:

resp=newFixedLengthResponse(Response.Status.OK,mime,mbuffer);

I'm completely lost on what the problem is, so any help would be very welcome.

Thanks,

Andrew.

@drandrewthomas
Copy link
Author

Hi again,

I decided to create a completely new project in the latest version of Android Studio, transferring the code into it as a clean new base for the project. The error I described above for AIDE running on Android didn't then happen in Android Studio on my Windows PC :-)

I don't know why this should happen in AIDE, but as it is probably an issue with older versions of gradle in AIDE projects it probably isn't an issue with NanoHTTPD. Therefore, I'll close this issue and hopefully anyone else having problems with NanoHTTPD in AIDE will find it for reference.

Many thanks,

Andrew.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant