-
Notifications
You must be signed in to change notification settings - Fork 29
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
response Transfer-Encoding: chunked error #9
Comments
Where did you get this error from? |
We are trying to parse google http response with chunk and gzip encoding, but what we get is Please check the attachements below. |
We are using the latest version of RawHttp. It seems a perfect http library we love. |
Ok... This is indeed a strange chunk Google is sending... my interpretation of the spec, though, seems to have been incorrect now that I look into it more carefully. RawHTTP does not allow chunk-sizes bigger than FFFF (65535 bytes), so it expects at most 4 hexa-decimal characters for I will change the code as soon as possible to fix this... It's an easy fix, so if you have urgency, you could probably do it yourselves for now. |
We are trying to solve the issue but in vain. Now we have no idea. I guess Google uses async request, and 0000001 means Async Not Ready. |
@WangGaofei fork this project, change this method to stop reading the chunk-size when it finds either a new line or Can you do that? |
I am not sure what does 00000001 and 0001 and 1 and 9 mean in the file. Or we can skip the section. |
What you want to do is parse the hex String up to either new-line or So, |
I've fixed the issue in the |
GOOD JOB. You are very nice and efficient. I need to go to Tianjin this morning. After that I will have a test. Thank you.@renatoathaydes |
No problem! Happy to help. Have a good trip :) |
Info update: File 144_c.txt is request, file 144_s.txt is response. Join 2 files with /r/n, then pass it into RawHttp. These files are generated in .saz format using fiddler. |
@renatoathaydes Thanks, I have gained the dev branch the latest code and run successfully.But I get the response of the body data is garbled.
Get the reponse of body data is as follows: I don't know what reason is this。 |
Can you try |
@renatoathaydes
|
Can you send me the response body you're having trouble with? Also the response headers so I know the encoding used. |
Ok. The request header data is in the file 144_c.txt
thanks! |
Ok, I found the problem. The response uses the following relevant headers:
RawHTTP cares only about the transfer encoding because that's within the realm of transferring the HTTP message - which RawHTTP is responsible for doing. The The spec says, further: _ Typically, the representation is only decoded just prior to rendering So, I believe the behaviour RawHTTP is presenting is correct in not unzipping the message body... however, that's not very helpful, I agree... so I think the best solution to this problem is to make the |
Thank you gave me answer over the weekend.This problem I also don't know how to deal with, can you give me a solution for the sample code? |
@renatoathaydes |
You can get your data for now by decompressing the body: byte[] body = response.getBody().get().decodeBody();
java.io.ByteArrayInputStream bytein = new java.io.ByteArrayInputStream(body);
java.util.zip.GZIPInputStream gzin = new java.util.zip.GZIPInputStream(bytein);
java.io.ByteArrayOutputStream byteout = new java.io.ByteArrayOutputStream();
int res = 0;
byte buf[] = new byte[1024];
while (res >= 0) {
res = gzin.read(buf, 0, buf.length);
if (res > 0) {
byteout.write(buf, 0, res);
}
}
byte[] uncompressed = byteout.toByteArray();
System.out.println(new String(uncompressed, StandardCharsets.UTF_8)); |
@renatoathaydes Because the data is according to block transmission, and it cannot be directly extract.
Have passed this test scheme。 |
The code I posted works... you're doing too much in your code that is not necessary. |
@renatoathaydes Thank you for your help. Your library is perfect and flexible. And we have made huge progress based on your library. We change the code a bit, it works like a charmer. Please look at the changes. It will unchunk and decompress the data automatically. You can perform a new release, I think. rawhttp.core.RawHttp
|
@LuPan2015 it's released now! |
error info
java.lang.IllegalStateException: Invalid chunk-size (too big, more than 4 hex-digits) at rawhttp.core.body.ChunkedBodyParser.readChunkSize(ChunkedBodyParser.java:215) at rawhttp.core.body.ChunkedBodyParser.parseChunkedBody(ChunkedBodyParser.java:97) at rawhttp.core.body.BodyConsumer$ChunkedBodyConsumer.consumeInto(BodyConsumer.java:93) null at rawhttp.core.body.BodyConsumer.consume(BodyConsumer.java:29) at rawhttp.core.body.EagerBodyReader.<init>(EagerBodyReader.java:35) at rawhttp.core.body.LazyBodyReader.eager(LazyBodyReader.java:68) at rawhttp.core.EagerHttpResponse.from(EagerHttpResponse.java:52) at rawhttp.core.RawHttpResponse.eagerly(RawHttpResponse.java:95) at rawhttp.core.RawHttpResponse.eagerly(RawHttpResponse.java:79)
The text was updated successfully, but these errors were encountered: