[dspace-tech] Re: Byte range requests in DSpace5

2018-03-08 Thread Anis
Quick follow up.

I want to clarify that this is concerning xmlui, if somebody is searching 
for a solution to this. I found out that byte-range requests were disabled 
in DSpace5 in 
here 
https://github.com/DSpace/DSpace/blob/dspace-5_x/dspace-xmlui/src/main/java/org/dspace/app/xmlui/cocoon/BitstreamReader.java#L646

Uncommenting didn't make it work, but after a bit of digging I got it to 
work by modifying the code to this

response.setHeader("Accept-Ranges", "bytes");
String ranges = request.getHeader("Range");
if (ranges != null)
{
try
{
ranges = ranges.substring(ranges.indexOf('=') + 1);
byteRange = new ByteRange(ranges);
}
catch (NumberFormatException e)
{
byteRange = null;
if (response instanceof HttpResponse)
{
// Respond with status 416 (Request range not
// satisfiable)
response.setStatus(416);
}
}
}

try
{
if (byteRange != null)
{
ByteRange actualByteRange = byteRange;
String entityLength;
String entityRange;
if (this.bitstreamSize != -1)
{
if(ranges.equals("0-")){
entityLength = "" + this.bitstreamSize;
actualByteRange = byteRange.intersection(new ByteRange(0, 
99));
entityRange = actualByteRange.toString();
} else {
entityLength = "" + this.bitstreamSize;
actualByteRange = byteRange.intersection(new ByteRange(0, 
this.bitstreamSize - 1));
entityRange = actualByteRange.toString();
}
}
else
{
entityLength = "*";
entityRange = byteRange.toString();
}

response.setHeader("Content-Range", "bytes " + entityRange + "/" + 
entityLength);
if(actualByteRange.length() != -1) {
response.setHeader("Content-Length", 
String.valueOf(actualByteRange.length()));
}

if (response instanceof HttpResponse)
{
// Response with status 206 (Partial content)
response.setStatus(206);
}


- Anis

On Wednesday, March 7, 2018 at 9:20:27 AM UTC+2, Anis wrote:
>
> Thank you! I'll look into this and test for possible side effects.
>
>
> On Tuesday, March 6, 2018 at 4:28:06 PM UTC+2, Mark H. Wood wrote:
>>
>> On Tuesday, March 6, 2018 at 3:16:37 AM UTC-5, Anis wrote:
>>>
>>> We're planning to add very simple video streaming support to our UI, by 
>>> basically adding a video tag if the file format is right. Now this simple 
>>> change has hit a pretty annoying wall, as the streaming works neatly in 
>>> every browser except Safari, because it requires byte range requests from 
>>> the server.
>>>
>>> I noticed that this is implemented in DSpace7 (
>>> https://github.com/DSpace/DSpace/pull/1884), but the architectural 
>>> changes are so big, that I'm not quite sure where the relevant parts would 
>>> be in the DSpace5 source. So quite simply I'm asking, where should I start 
>>> looking into, in the source, to backport this to 5?
>>>
>>
>>
>> In XMLUI byte ranges are explicitly disabled in 
>> dspace-xmlui/src/main/java/org/dspace/app/xmlui/cocoon/ConcatenationReader.java
>>  
>> around line 68.
>>
>> I vaguely recall that DSpace did support byte-range requests at one time 
>> but that it was taken out to fix some other problem.  But my memory may be 
>> faulty. 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dspace-tech+unsubscr...@googlegroups.com.
To post to this group, send email to dspace-tech@googlegroups.com.
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.


[dspace-tech] Re: Byte range requests in DSpace5

2018-03-06 Thread Anis
Thank you! I'll look into this and test for possible side effects.


On Tuesday, March 6, 2018 at 4:28:06 PM UTC+2, Mark H. Wood wrote:
>
> On Tuesday, March 6, 2018 at 3:16:37 AM UTC-5, Anis wrote:
>>
>> We're planning to add very simple video streaming support to our UI, by 
>> basically adding a video tag if the file format is right. Now this simple 
>> change has hit a pretty annoying wall, as the streaming works neatly in 
>> every browser except Safari, because it requires byte range requests from 
>> the server.
>>
>> I noticed that this is implemented in DSpace7 (
>> https://github.com/DSpace/DSpace/pull/1884), but the architectural 
>> changes are so big, that I'm not quite sure where the relevant parts would 
>> be in the DSpace5 source. So quite simply I'm asking, where should I start 
>> looking into, in the source, to backport this to 5?
>>
>
>
> In XMLUI byte ranges are explicitly disabled in 
> dspace-xmlui/src/main/java/org/dspace/app/xmlui/cocoon/ConcatenationReader.java
>  
> around line 68.
>
> I vaguely recall that DSpace did support byte-range requests at one time 
> but that it was taken out to fix some other problem.  But my memory may be 
> faulty. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dspace-tech+unsubscr...@googlegroups.com.
To post to this group, send email to dspace-tech@googlegroups.com.
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.


[dspace-tech] Re: Byte range requests in DSpace5

2018-03-06 Thread Mark H. Wood
On Tuesday, March 6, 2018 at 3:16:37 AM UTC-5, Anis wrote:
>
> We're planning to add very simple video streaming support to our UI, by 
> basically adding a video tag if the file format is right. Now this simple 
> change has hit a pretty annoying wall, as the streaming works neatly in 
> every browser except Safari, because it requires byte range requests from 
> the server.
>
> I noticed that this is implemented in DSpace7 (
> https://github.com/DSpace/DSpace/pull/1884), but the architectural 
> changes are so big, that I'm not quite sure where the relevant parts would 
> be in the DSpace5 source. So quite simply I'm asking, where should I start 
> looking into, in the source, to backport this to 5?
>


In XMLUI byte ranges are explicitly disabled in 
dspace-xmlui/src/main/java/org/dspace/app/xmlui/cocoon/ConcatenationReader.java 
around line 68.

I vaguely recall that DSpace did support byte-range requests at one time 
but that it was taken out to fix some other problem.  But my memory may be 
faulty. 

-- 
You received this message because you are subscribed to the Google Groups 
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dspace-tech+unsubscr...@googlegroups.com.
To post to this group, send email to dspace-tech@googlegroups.com.
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.